Mageia Bugzilla – Attachment 8528 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]
complete the patch to get the correct size
URPM-overflow-attempt3-works.patch (text/plain), 2.28 KB, created by
Giuseppe Ghibò
on 2016-10-13 23:45:05 CEST
(
hide
)
Description:
complete the patch to get the correct size
Filename:
MIME Type:
Creator:
Giuseppe Ghibò
Created:
2016-10-13 23:45:05 CEST
Size:
2.28 KB
patch
obsolete
>diff -up URPM-5.07/URPM.xs.64bit URPM-5.07/URPM.xs >--- URPM-5.07/URPM.xs.64bit 2016-04-14 18:16:51.000000000 +0200 >+++ URPM-5.07/URPM.xs 2016-10-13 17:54:10.213554256 +0200 >@@ -46,7 +46,7 @@ typedef struct rpmSpec_s * Spec; > > struct s_Package { > Header h; >- int filesize; >+ unsigned int filesize; > unsigned flag; > char *info; > char *requires; >@@ -201,18 +201,17 @@ get_arch(const Header header) { > 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 > get_filesize(const Header h) { >- return headerGetNumber(h, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ >+ return headerGetNumber(h, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ > } > > static int >@@ -756,7 +755,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@%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); >@@ -1750,7 +1749,7 @@ Pkg_compare(pkg, evr) > OUTPUT: > RETVAL > >-int >+unsigned int > Pkg_size(pkg) > URPM::Package pkg > CODE: >@@ -1778,7 +1777,7 @@ Pkg_set_filesize(pkg, filesize) > PPCODE: > pkg->filesize = filesize; > >-int >+unsigned int > Pkg_filesize(pkg) > URPM::Package pkg > CODE: >@@ -2120,7 +2119,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@%u\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.07/URPM.xs.64bit URPM-5.07/URPM.xs --- URPM-5.07/URPM.xs.64bit 2016-04-14 18:16:51.000000000 +0200 +++ URPM-5.07/URPM.xs 2016-10-13 17:54:10.213554256 +0200 @@ -46,7 +46,7 @@ typedef struct rpmSpec_s * Spec; struct s_Package { Header h; - int filesize; + unsigned int filesize; unsigned flag; char *info; char *requires; @@ -201,18 +201,17 @@ get_arch(const Header header) { 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 get_filesize(const Header h) { - return headerGetNumber(h, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ + return headerGetNumber(h, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ } static int @@ -756,7 +755,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@%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); @@ -1750,7 +1749,7 @@ Pkg_compare(pkg, evr) OUTPUT: RETVAL -int +unsigned int Pkg_size(pkg) URPM::Package pkg CODE: @@ -1778,7 +1777,7 @@ Pkg_set_filesize(pkg, filesize) PPCODE: pkg->filesize = filesize; -int +unsigned int Pkg_filesize(pkg) URPM::Package pkg CODE: @@ -2120,7 +2119,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@%u\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