Browse Source

Cherry-pick from upstream: Handle [elf] files without program headers gracefully. Closes: #882310

Christoph Biedl 5 years ago
parent
commit
bff67b6e05

+ 44 - 0
debian/patches/cherry-pick.FILE5_34-2-gedb7f0d6.pr-9-christoph-bield-handle-files-without-program-headers-gracefully.patch

@@ -0,0 +1,44 @@
+Subject: PR/9: Christoph Bield: Handle files without program headers gracefully
+Origin: FILE5_34-2-gedb7f0d6 <https://github.com/file/file/commit/FILE5_34-2-gedb7f0d6>
+Upstream-Author: Christos Zoulas <christos@zoulas.com>
+Date: Wed Jul 25 06:12:09 2018 +0000
+Bug-Debian: https://bugs.debian.org/882310
+
+--- a/src/readelf.c
++++ b/src/readelf.c
+@@ -352,6 +352,11 @@
+ 	off_t ph_off = off;
+ 	int ph_num = num;
+ 
++	if (num == 0) {
++		if (file_printf(ms, ", no program header") == -1)
++			return -1;
++		return 0;
++	}
+ 	if (size != xph_sizeof) {
+ 		if (file_printf(ms, ", corrupted program header size") == -1)
+ 			return -1;
+@@ -1278,6 +1283,11 @@
+ 	char name[50];
+ 	ssize_t namesize;
+ 
++	if (num == 0) {
++		if (file_printf(ms, ", no section header") == -1)
++			return -1;
++		return 0;
++	}
+ 	if (size != xsh_sizeof) {
+ 		if (file_printf(ms, ", corrupted section header size") == -1)
+ 			return -1;
+@@ -1549,6 +1559,11 @@
+ 	ssize_t bufsize;
+ 	size_t offset, align, len;
+ 	
++	if (num == 0) {
++		if (file_printf(ms, ", no program header") == -1)
++			return -1;
++		return 0;
++	}
+ 	if (size != xph_sizeof) {
+ 		if (file_printf(ms, ", corrupted program header size") == -1)
+ 			return -1;

+ 1 - 0
debian/patches/series

@@ -1,4 +1,5 @@
 # cherry-picked commits. Keep in upstream's chronological order
+cherry-pick.FILE5_34-2-gedb7f0d6.pr-9-christoph-bield-handle-files-without-program-headers-gracefully.patch
 
 # patches that should go upstream
 upstream.coff-amd64.patch