Fix: potential close() of uninitialized elf_fd
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 2 May 2016 20:27:58 +0000 (16:27 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 May 2016 19:42:43 +0000 (15:42 -0400)
elf_fd is uninitialized whenever bin is NULL.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/bin-info.c

index 813c6830e8717c6f7cd1bd081accead14e27bca4..e5d515005125510e0537603e05d299aac904839c 100644 (file)
@@ -482,7 +482,7 @@ end:
 static
 int bin_info_set_elf_file(struct bin_info *bin)
 {
-       int elf_fd;
+       int elf_fd = -1;
        Elf *elf_file = NULL;
 
        if (!bin) {
@@ -512,7 +512,9 @@ int bin_info_set_elf_file(struct bin_info *bin)
        return 0;
 
 error:
-       close(elf_fd);
+       if (elf_fd >= 0) {
+               close(elf_fd);
+       }
        elf_end(elf_file);
        return -1;
 }
This page took 0.036204 seconds and 4 git commands to generate.