| 
					
				 | 
			
			
				@@ -0,0 +1,55 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+strip.c: Pointer `arhdr` created at strip.c:2741 and then dereferenced without NULL-check. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+The same situation for the `arhdr` pointer at the objdump.c:313 and 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+the `h` pointer at the readelf.c:13545. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+Triggers found by static analyzer Svace. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+Signed-off-by: Maks Mishin <[email protected]> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+--- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ src/objdump.c | 5 +++++ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ src/readelf.c | 5 +++++ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ src/strip.c   | 5 +++++ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 3 files changed, 15 insertions(+) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+--- a/src/objdump.c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++++ b/src/objdump.c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@@ -311,6 +311,11 @@ handle_ar (int fd, Elf *elf, const char 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       /* The the header for this element.  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       Elf_Arhdr *arhdr = elf_getarhdr (subelf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++      if (arhdr == NULL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	  printf ("cannot get arhdr: %s\n", elf_errmsg (-1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	  exit (1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       /* Skip over the index entries.  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       if (strcmp (arhdr->ar_name, "/") != 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+--- a/src/readelf.c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++++ b/src/readelf.c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@@ -13543,6 +13543,11 @@ dump_archive_index (Elf *elf, const char 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 			  as_off, fname, elf_errmsg (-1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 	  const Elf_Arhdr *h = elf_getarhdr (subelf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	  if (h == NULL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	  printf ("cannot get arhdr: %s\n", elf_errmsg (-1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	  exit (1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 	  printf (_("Archive member '%s' contains:\n"), h->ar_name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+--- a/src/strip.c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++++ b/src/strip.c 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@@ -2739,6 +2739,11 @@ handle_ar (int fd, Elf *elf, const char 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       /* The the header for this element.  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       Elf_Arhdr *arhdr = elf_getarhdr (subelf); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	  if (arhdr == NULL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	  printf ("cannot get arhdr: %s\n", elf_errmsg (-1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	  exit (1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				++	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       if (elf_kind (subelf) == ELF_K_ELF) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 	result |= handle_elf (fd, subelf, new_prefix, arhdr->ar_name, 0, NULL); 
			 |