]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-file-readelf-fix.patch
- fixed (s/-bi/-bb/) and enhanced comment
[packages/rpm.git] / rpm-file-readelf-fix.patch
CommitLineData
30427c58 1--- rpm-4.3/file/src/readelf.c.orig 2004-03-19 21:12:58.000000000 +0100
7e18e7ef 2+++ rpm-4.3/file/src/readelf.c 2004-03-19 23:14:04.924440965 +0100
30427c58
JB
3@@ -136,6 +136,9 @@
4 getu32(fm, ph32.p_align) : 4) \
5 : (off_t) (ph64.p_align ? \
6 getu64(fm, ph64.p_align) : 4)))
7+#define ph_filesz (fm->cls == ELFCLASS32 \
8+ ? getu32(fm, ph32.p_filesz) \
9+ : getu64(fm, ph64.p_filesz))
10 #define nh_size (fm->cls == ELFCLASS32 \
11 ? sizeof nh32 \
12 : sizeof nh64)
13@@ -244,7 +247,7 @@
14 error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
15 /*@notreached@*/
16 }
17- bufsize = read(fm->fd, nbuf, BUFSIZ);
18+ bufsize = read(fm->fd, nbuf, ((ph_filesz < BUFSIZ) ? ph_filesz : BUFSIZ));
19 if (bufsize == -1) {
20 error(EXIT_FAILURE, 0, ": " "read failed (%s).\n", strerror(errno));
21 /*@notreached@*/
7e18e7ef
JB
22@@ -290,7 +293,7 @@
23 noff = offset;
24 doff = ELF_ALIGN(offset + nh_namesz);
25
26- if (offset + nh_namesz >= size) {
27+ if (doff > size) {
28 /*
29 * We're past the end of the buffer.
30 */
31@@ -298,7 +301,7 @@
32 }
33
34 offset = ELF_ALIGN(doff + nh_descsz);
35- if (offset + nh_descsz >= size)
36+ if (offset > size)
37 return offset;
38
39 if (nh_namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
30427c58
JB
40@@ -601,7 +604,8 @@
41 error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
42 /*@notreached@*/
43 }
44- bufsize = read(fm->fd, nbuf, sizeof(nbuf));
45+ bufsize = read(fm->fd, nbuf,
46+ ((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 +618,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 }
This page took 0.044034 seconds and 4 git commands to generate.