Mageia Bugzilla – Attachment 8529 Details for
Bug 19571
overflow when querying for size with urpmq
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
attempt for getting the right package size
URPM-overflow-attempt4-unsignedlong-rpmsize-doesntwork.patch (text/plain), 3.44 KB, created by
Giuseppe Ghibò
on 2016-10-13 23:48:09 CEST
(
hide
)
Description:
attempt for getting the right package size
Filename:
MIME Type:
Creator:
Giuseppe Ghibò
Created:
2016-10-13 23:48:09 CEST
Size:
3.44 KB
patch
obsolete
>diff -w -uNr URPM-5.07.orig/URPM.pm URPM-5.07/URPM.pm >--- URPM-5.07.orig/URPM.pm 2016-04-14 18:10:22.000000000 +0200 >+++ URPM-5.07/URPM.pm 2016-10-13 23:24:13.667764923 +0200 >@@ -1008,7 +1008,7 @@ > } } > > B<rejected>: { fullname => { >- size => int, removed => { fullname|"asked" => undef }, >+ size => unsigned long, removed => { fullname|"asked" => undef }, > obsoleted => { fullname|"asked" => undef }, > backtrack => { # those info are only used to display why package is unselected > promote => [ name ], keep => [ fullname ], >diff -w -uNr URPM-5.07.orig/URPM.xs URPM-5.07/URPM.xs >--- URPM-5.07.orig/URPM.xs 2016-04-14 18:16:51.000000000 +0200 >+++ URPM-5.07/URPM.xs 2016-10-13 23:24:13.668764921 +0200 >@@ -46,7 +46,7 @@ > > struct s_Package { > Header h; >- int filesize; >+ unsigned long filesize; > unsigned flag; > char *info; > char *requires; >@@ -201,13 +201,12 @@ > return headerIsEntry(header, RPMTAG_SOURCERPM) ? get_name(header, RPMTAG_ARCH) : "src"; > } > >-static int >+static uint64_t > get_int(const Header header, rpmTag tag) { > struct rpmtd_s val; > >- headerGet(header, tag, &val, HEADERGET_DEFAULT); >- uint32_t *ep = rpmtdGetUint32(&val); >- return ep ? *ep : 0; >+ headerGet(header, tag, &val, HEADERGET_ALLOC); >+ return rpmtdGetNumber(&val); > } > > static size_t >@@ -756,7 +755,7 @@ > const char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR); > const char *arch = get_arch(pkg->h); > >- p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%d@%d@%s", nvr, arch, >+ p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%lu@%lu@%s", nvr, arch, > get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE), > get_name(pkg->h, RPMTAG_GROUP)); > pkg->info = memcpy(malloc(p-buff), buff, p-buff); >@@ -961,7 +960,7 @@ > > fd = open(filename, O_RDONLY); > if (fd >= 0) { >- int pos = lseek(fd, -(int)sizeof(buf), SEEK_END); >+ off_t pos = lseek(fd, -(off_t)sizeof(buf), SEEK_END); > if (read(fd, &buf, sizeof(buf)) != sizeof(buf) || strncmp(buf.header, "cz[0", 4) || strncmp(buf.trailer, "0]cz", 4)) { > /* this is not an archive, open it without magic, but first rewind at begin of file */ > lseek(fd, 0, SEEK_SET); >@@ -1046,7 +1045,7 @@ > // reset package, next line will be for another one > memset(pkg, 0, sizeof(struct s_Package)); > } else if (!strcmp(tag, "filesize")) >- pkg->filesize = atoi(data); >+ pkg->filesize = atol(data); > else { > char **ptr = NULL; > if (!strcmp(tag, "requires")) >@@ -1750,7 +1749,7 @@ > OUTPUT: > RETVAL > >-int >+unsigned long > Pkg_size(pkg) > URPM::Package pkg > CODE: >@@ -1760,7 +1759,7 @@ > if ((s = strchr(pkg->info, '@')) != NULL && (s = strchr(s+1, '@')) != NULL) { > if ((eos = strchr(s+1, '@')) != NULL) > *eos = 0; /* mark end of string to enable searching backwards */ >- RETVAL = atoi(s+1); >+ RETVAL = atol(s+1); > if (eos != NULL) *eos = '@'; > } else > RETVAL = 0; >@@ -1778,7 +1777,7 @@ > PPCODE: > pkg->filesize = filesize; > >-int >+unsigned long > Pkg_filesize(pkg) > URPM::Package pkg > CODE: >@@ -2120,7 +2119,7 @@ > if (size < sizeof(buff)) write_nocheck(fileno, buff, size); > } > if (pkg->filesize) { >- size = snprintf(buff, sizeof(buff), "@filesize@%d\n", pkg->filesize); >+ size = snprintf(buff, sizeof(buff), "@filesize@%lu\n", pkg->filesize); > if (size < sizeof(buff)) write_nocheck(fileno, buff, size); > } > size = snprintf(buff, sizeof(buff), "@info@%s\n", pkg->info);
diff -w -uNr URPM-5.07.orig/URPM.pm URPM-5.07/URPM.pm --- URPM-5.07.orig/URPM.pm 2016-04-14 18:10:22.000000000 +0200 +++ URPM-5.07/URPM.pm 2016-10-13 23:24:13.667764923 +0200 @@ -1008,7 +1008,7 @@ } } B<rejected>: { fullname => { - size => int, removed => { fullname|"asked" => undef }, + size => unsigned long, removed => { fullname|"asked" => undef }, obsoleted => { fullname|"asked" => undef }, backtrack => { # those info are only used to display why package is unselected promote => [ name ], keep => [ fullname ], diff -w -uNr URPM-5.07.orig/URPM.xs URPM-5.07/URPM.xs --- URPM-5.07.orig/URPM.xs 2016-04-14 18:16:51.000000000 +0200 +++ URPM-5.07/URPM.xs 2016-10-13 23:24:13.668764921 +0200 @@ -46,7 +46,7 @@ struct s_Package { Header h; - int filesize; + unsigned long filesize; unsigned flag; char *info; char *requires; @@ -201,13 +201,12 @@ return headerIsEntry(header, RPMTAG_SOURCERPM) ? get_name(header, RPMTAG_ARCH) : "src"; } -static int +static uint64_t get_int(const Header header, rpmTag tag) { struct rpmtd_s val; - headerGet(header, tag, &val, HEADERGET_DEFAULT); - uint32_t *ep = rpmtdGetUint32(&val); - return ep ? *ep : 0; + headerGet(header, tag, &val, HEADERGET_ALLOC); + return rpmtdGetNumber(&val); } static size_t @@ -756,7 +755,7 @@ const char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR); const char *arch = get_arch(pkg->h); - p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%d@%d@%s", nvr, arch, + p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%lu@%lu@%s", nvr, arch, get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE), get_name(pkg->h, RPMTAG_GROUP)); pkg->info = memcpy(malloc(p-buff), buff, p-buff); @@ -961,7 +960,7 @@ fd = open(filename, O_RDONLY); if (fd >= 0) { - int pos = lseek(fd, -(int)sizeof(buf), SEEK_END); + off_t pos = lseek(fd, -(off_t)sizeof(buf), SEEK_END); if (read(fd, &buf, sizeof(buf)) != sizeof(buf) || strncmp(buf.header, "cz[0", 4) || strncmp(buf.trailer, "0]cz", 4)) { /* this is not an archive, open it without magic, but first rewind at begin of file */ lseek(fd, 0, SEEK_SET); @@ -1046,7 +1045,7 @@ // reset package, next line will be for another one memset(pkg, 0, sizeof(struct s_Package)); } else if (!strcmp(tag, "filesize")) - pkg->filesize = atoi(data); + pkg->filesize = atol(data); else { char **ptr = NULL; if (!strcmp(tag, "requires")) @@ -1750,7 +1749,7 @@ OUTPUT: RETVAL -int +unsigned long Pkg_size(pkg) URPM::Package pkg CODE: @@ -1760,7 +1759,7 @@ if ((s = strchr(pkg->info, '@')) != NULL && (s = strchr(s+1, '@')) != NULL) { if ((eos = strchr(s+1, '@')) != NULL) *eos = 0; /* mark end of string to enable searching backwards */ - RETVAL = atoi(s+1); + RETVAL = atol(s+1); if (eos != NULL) *eos = '@'; } else RETVAL = 0; @@ -1778,7 +1777,7 @@ PPCODE: pkg->filesize = filesize; -int +unsigned long Pkg_filesize(pkg) URPM::Package pkg CODE: @@ -2120,7 +2119,7 @@ if (size < sizeof(buff)) write_nocheck(fileno, buff, size); } if (pkg->filesize) { - size = snprintf(buff, sizeof(buff), "@filesize@%d\n", pkg->filesize); + size = snprintf(buff, sizeof(buff), "@filesize@%lu\n", pkg->filesize); if (size < sizeof(buff)) write_nocheck(fileno, buff, size); } size = snprintf(buff, sizeof(buff), "@info@%s\n", pkg->info);
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 19571
:
8522
|
8523
|
8525
|
8528
|
8529
|
8530
|
8531
|
8537
|
8538
|
8539
|
8541
|
8542
|
8543
|
8547
|
8548
|
8549
|
8563
|
8564
|
8565
|
8566