]> granicus.if.org Git - file/commitdiff
we don't just read the header size, but the whole note too; so revert the
authorChristos Zoulas <christos@zoulas.com>
Sat, 24 Jul 2004 20:57:22 +0000 (20:57 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sat, 24 Jul 2004 20:57:22 +0000 (20:57 +0000)
previous buffer fix.

src/readelf.c

index ec63a5ead0bb8de5b4db77d2f7a0472473230362..ccfa491af08d27c4704ce5d61dc113d4acee6d4d 100644 (file)
@@ -39,7 +39,7 @@
 #include "readelf.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: readelf.c,v 1.41 2004/07/24 20:38:56 christos Exp $")
+FILE_RCSID("@(#)$Id: readelf.c,v 1.42 2004/07/24 20:57:22 christos Exp $")
 #endif
 
 #ifdef ELFCORE
@@ -150,6 +150,9 @@ getu64(int swap, uint64_t value)
 #define ph_filesz      (size_t)((class == ELFCLASS32   \
                         ? getu32(swap, ph32.p_filesz)  \
                         : getu64(swap, ph64.p_filesz)))
+#define ph_memsz       (size_t)((class == ELFCLASS32   \
+                        ? getu32(swap, ph32.p_memsz)   \
+                        : getu64(swap, ph64.p_memsz)))
 #define nh_size                (class == ELFCLASS32            \
                         ? sizeof nh32                  \
                         : sizeof nh64)
@@ -253,8 +256,7 @@ dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off,
                        file_badseek(ms);
                        return -1;
                }
-               bufsize = read(fd, nbuf,
-                   ((ph_filesz < BUFSIZ) ? ph_filesz : BUFSIZ));
+               bufsize = read(fd, nbuf, sizeof(nbuf));
                if (bufsize == -1) {
                        file_badread(ms);
                        return -1;
@@ -691,9 +693,7 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
                                file_badseek(ms);
                                return -1;
                        }
-                       bufsize = read(fd, nbuf,
-                           ((ph_filesz < sizeof(nbuf)) ?
-                           ph_filesz : sizeof(nbuf)));
+                       bufsize = read(fd, nbuf, sizeof(nbuf));
                        if (bufsize == -1) {
                                file_badread(ms);
                                return -1;