Mageia Bugzilla – Attachment 8542 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]
patch for getting right size for files >= 4GB
perl-URPM-overflow-uint64_t.patch (text/plain), 3.13 KB, created by
Giuseppe Ghibò
on 2016-10-15 22:33:07 CEST
(
hide
)
Description:
patch for getting right size for files >= 4GB
Filename:
MIME Type:
Creator:
Giuseppe Ghibò
Created:
2016-10-15 22:33:07 CEST
Size:
3.13 KB
patch
obsolete
>diff -up URPM-5.08/URPM.xs.64bit URPM-5.08/URPM.xs >--- URPM-5.08/URPM.xs.64bit 2016-10-15 21:46:41.977332566 +0200 >+++ URPM-5.08/URPM.xs 2016-10-15 21:56:13.398109793 +0200 >@@ -46,7 +46,7 @@ typedef struct rpmSpec_s * Spec; > > struct s_Package { > Header h; >- int filesize; >+ uint64_t filesize; > unsigned flag; > char *info; > char *requires; >@@ -209,9 +209,18 @@ get_int(const Header header, rpmTag tag) > return rpmtdGetNumber(&val); > } > >-static size_t >+static uint64_t >+get_int2(const Header header, rpmTag newtag, rpmTag oldtag) { >+ struct rpmtd_s val; >+ >+ if (!headerGet(header, newtag, &val, HEADERGET_DEFAULT)) >+ headerGet(header, oldtag, &val, HEADERGET_DEFAULT); >+ return rpmtdGetNumber(&val); >+} >+ >+static uint64_t > get_filesize(const Header h) { >- return headerGetNumber(h, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ >+ return get_int2(h, RPMTAG_LONGSIGSIZE, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ > } > > static int >@@ -758,7 +767,7 @@ pack_header(const URPM__Package pkg) { > const char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR); > const char *arch = get_arch(pkg->h); > p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%llu@%llu@%s", nvr, arch, >- get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE), >+ get_int(pkg->h, RPMTAG_EPOCH), get_int2(pkg->h, RPMTAG_LONGSIZE, RPMTAG_SIZE), > get_name(pkg->h, RPMTAG_GROUP)); > pkg->info = memcpy(malloc(p-buff), buff, p-buff); > } >@@ -1047,7 +1056,7 @@ parse_line(AV *depslist, HV *provides, H > // 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 = atoll(data); > else { > char **ptr = NULL; > if (!strcmp(tag, "requires")) >@@ -1751,7 +1760,7 @@ Pkg_compare(pkg, evr) > OUTPUT: > RETVAL > >-int >+unsigned long > Pkg_size(pkg) > URPM::Package pkg > CODE: >@@ -1761,12 +1770,12 @@ Pkg_size(pkg) > 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 = (unsigned long) atoll(s+1); > if (eos != NULL) *eos = '@'; > } else > RETVAL = 0; > } else if (pkg->h) >- RETVAL = get_int(pkg->h, RPMTAG_SIZE); >+ RETVAL = (unsigned long) get_int2(pkg->h, RPMTAG_LONGSIZE, RPMTAG_SIZE); > else > RETVAL = 0; > OUTPUT: >@@ -1779,7 +1788,7 @@ Pkg_set_filesize(pkg, filesize) > PPCODE: > pkg->filesize = filesize; > >-int >+unsigned long > Pkg_filesize(pkg) > URPM::Package pkg > CODE: >@@ -2121,7 +2130,7 @@ Pkg_build_info(pkg, fileno, provides_fil > 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@%llu\n", pkg->filesize); > if (size < sizeof(buff)) write_nocheck(fileno, buff, size); > } > size = snprintf(buff, sizeof(buff), "@info@%s\n", pkg->info);
diff -up URPM-5.08/URPM.xs.64bit URPM-5.08/URPM.xs --- URPM-5.08/URPM.xs.64bit 2016-10-15 21:46:41.977332566 +0200 +++ URPM-5.08/URPM.xs 2016-10-15 21:56:13.398109793 +0200 @@ -46,7 +46,7 @@ typedef struct rpmSpec_s * Spec; struct s_Package { Header h; - int filesize; + uint64_t filesize; unsigned flag; char *info; char *requires; @@ -209,9 +209,18 @@ get_int(const Header header, rpmTag tag) return rpmtdGetNumber(&val); } -static size_t +static uint64_t +get_int2(const Header header, rpmTag newtag, rpmTag oldtag) { + struct rpmtd_s val; + + if (!headerGet(header, newtag, &val, HEADERGET_DEFAULT)) + headerGet(header, oldtag, &val, HEADERGET_DEFAULT); + return rpmtdGetNumber(&val); +} + +static uint64_t get_filesize(const Header h) { - return headerGetNumber(h, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ + return get_int2(h, RPMTAG_LONGSIGSIZE, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ } static int @@ -758,7 +767,7 @@ pack_header(const URPM__Package pkg) { const char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR); const char *arch = get_arch(pkg->h); p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%llu@%llu@%s", nvr, arch, - get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE), + get_int(pkg->h, RPMTAG_EPOCH), get_int2(pkg->h, RPMTAG_LONGSIZE, RPMTAG_SIZE), get_name(pkg->h, RPMTAG_GROUP)); pkg->info = memcpy(malloc(p-buff), buff, p-buff); } @@ -1047,7 +1056,7 @@ parse_line(AV *depslist, HV *provides, H // 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 = atoll(data); else { char **ptr = NULL; if (!strcmp(tag, "requires")) @@ -1751,7 +1760,7 @@ Pkg_compare(pkg, evr) OUTPUT: RETVAL -int +unsigned long Pkg_size(pkg) URPM::Package pkg CODE: @@ -1761,12 +1770,12 @@ Pkg_size(pkg) 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 = (unsigned long) atoll(s+1); if (eos != NULL) *eos = '@'; } else RETVAL = 0; } else if (pkg->h) - RETVAL = get_int(pkg->h, RPMTAG_SIZE); + RETVAL = (unsigned long) get_int2(pkg->h, RPMTAG_LONGSIZE, RPMTAG_SIZE); else RETVAL = 0; OUTPUT: @@ -1779,7 +1788,7 @@ Pkg_set_filesize(pkg, filesize) PPCODE: pkg->filesize = filesize; -int +unsigned long Pkg_filesize(pkg) URPM::Package pkg CODE: @@ -2121,7 +2130,7 @@ Pkg_build_info(pkg, fileno, provides_fil 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@%llu\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