]>
Commit | Line | Data |
---|---|---|
1 | diff -ur rpm.org/file/src/readelf.c rpm/file/src/readelf.c | |
2 | --- rpm.org/file/src/readelf.c 2004-06-14 17:19:46.426166808 +0200 | |
3 | +++ rpm/file/src/readelf.c 2004-06-14 17:24:43.083068104 +0200 | |
4 | @@ -136,6 +136,9 @@ | |
5 | getu32(fm, ph32.p_align) : 4) \ | |
6 | : (off_t) (ph64.p_align ? \ | |
7 | getu64(fm, ph64.p_align) : 4))) | |
8 | +#define ph_filesz (fm->cls == ELFCLASS32 \ | |
9 | + ? getu32(fm, ph32.p_filesz) \ | |
10 | + : getu64(fm, ph64.p_filesz)) | |
11 | #define nh_size (fm->cls == ELFCLASS32 \ | |
12 | ? sizeof nh32 \ | |
13 | : sizeof nh64) | |
14 | @@ -244,7 +247,7 @@ | |
15 | error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno)); | |
16 | /*@notreached@*/ | |
17 | } | |
18 | - bufsize = read(fm->fd, nbuf, BUFSIZ); | |
19 | + bufsize = read(fm->fd, nbuf, ((ph_filesz < BUFSIZ) ? ph_filesz : BUFSIZ)); | |
20 | if (bufsize == -1) { | |
21 | error(EXIT_FAILURE, 0, ": " "read failed (%s).\n", strerror(errno)); | |
22 | /*@notreached@*/ | |
23 | @@ -290,7 +293,7 @@ | |
24 | noff = offset; | |
25 | doff = ELF_ALIGN(offset + nh_namesz); | |
26 | ||
27 | - if (offset + nh_namesz >= size) { | |
28 | + if (offset + nh_namesz > size) { | |
29 | /* | |
30 | * We're past the end of the buffer. | |
31 | */ | |
32 | @@ -298,7 +301,7 @@ | |
33 | } | |
34 | ||
35 | offset = ELF_ALIGN(doff + nh_descsz); | |
36 | - if (offset + nh_descsz >= size) | |
37 | + if (doff + nh_descsz > size) | |
38 | return offset; | |
39 | ||
40 | if (nh_namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 && | |
41 | @@ -601,7 +604,7 @@ | |
42 | error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno)); | |
43 | /*@notreached@*/ | |
44 | } | |
45 | - bufsize = read(fm->fd, nbuf, sizeof(nbuf)); | |
46 | + bufsize = read(fm->fd, nbuf, ((ph_filesz < sizeof(nbuf)) ? ph_filesz : sizeof(nbuf))); | |
47 | if (bufsize == -1) { | |
48 | error(EXIT_FAILURE, 0, ": " "read failed (%s).\n", | |
49 | strerror(errno)); | |
50 | @@ -614,7 +617,7 @@ | |
51 | offset = donote(fm, nbuf, offset, | |
52 | (size_t)bufsize, ph_align); | |
53 | } | |
54 | - if ((lseek(fm->fd, savedoffset + offset, SEEK_SET)) == (off_t)-1) { | |
55 | + if ((lseek(fm->fd, savedoffset, SEEK_SET)) == (off_t)-1) { | |
56 | error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno)); | |
57 | /*@notreached@*/ | |
58 | } |