[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [debian-lts] file package



Nguyen Cong wrote...

> Uhm, since my patch is bad and you do have updated file package,
> so could you please take care the rest for me.

Don't worry, it's not bad. It's the logical result of applying the
fix, but even I was rather surprised to learn it was just incomplete.

However, it wasn't until yesterday when I realized creating an
additional check like in


diff --git a/src/elfclass.h b/src/elfclass.h
index 2150a56..fbf4fb8 100644
--- a/src/elfclass.h
+++ b/src/elfclass.h
@@ -67,7 +67,8 @@
 		    (off_t)elf_getu(swap, elfhdr.e_shoff), shnum,
 		    (size_t)elf_getu16(swap, elfhdr.e_shentsize),
 		    &flags,
-		    elf_getu16(swap, elfhdr.e_machine)) == -1)
+		    elf_getu16(swap, elfhdr.e_machine),
+		    (int)elf_getu16(swap, elfhdr.e_shstrndx)) == -1)
 			return -1;
 		break;
 
diff --git a/src/readelf.c b/src/readelf.c
index a1157df..b9b6d4b 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -48,7 +48,7 @@ private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t,
 private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
     off_t, int *, int);
 private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, int *,
-    int);
+    int, int);
 private size_t donote(struct magic_set *, void *, size_t, size_t, int,
     int, size_t, int *);
 
@@ -854,7 +854,7 @@ static const cap_desc_t cap_desc_386[] = {
 
 private int
 doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
-    size_t size, int *flags, int mach)
+    size_t size, int *flags, int mach, int strtab)
 {
 	Elf32_Shdr sh32;
 	Elf64_Shdr sh64;
@@ -871,7 +871,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
 		return 0;
 	}
 
-	if (lseek(fd, off, SEEK_SET) == (off_t)-1) {
+	if (lseek(fd, off + size * strtab, SEEK_SET) == (off_t)-1) {
 		file_badseek(ms);
 		return -1;
 	}


(all hunks but the last are just prerequisites)

creates a new regression on some files ("error reading (Invalid
argument)"), /lib/ld-2.11.3.so in squeze-lts/amd64
(md5:8eab939972c75abff8e1080bc9d33f9d) to start with. If you have an
idea how to proceed from here, feel free.

> >For the records, I cannot see an attempt to contact me beforehand
> >about this.
> Sorry about this, this will be done in my next contribution.

Thanks for that, given the past experiences with regressions
introduced in file updates I'd really like to keep an eye on it. I
have a huge collection of test files that help me to identify
unexpected side effects, total run time is several hours - but cannot
disclose it for legal reasons.

    Christoph

Attachment: signature.asc
Description: Digital signature


Reply to: