Move RPMSIGTAG_SIZE vs PMSIGTAG_LONGSIZE detection to rpmGenDigest()

Fixes problem with rpmSign() only using RPMSIGTAG_SIZE
Fixes rh#1012595 for now as we are only moving to PMSIGTAG_LONGSIZE when needed
This commit is contained in:
Florian Festi 2013-09-30 16:08:57 +02:00
parent 09fb3830b6
commit 116a6f7105
2 changed files with 17 additions and 20 deletions

View File

@ -257,7 +257,6 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
int xx; int xx;
rpmRC rc = RPMRC_OK; rpmRC rc = RPMRC_OK;
struct rpmtd_s td; struct rpmtd_s td;
rpmTagVal sizetag;
rpmTagVal payloadtag; rpmTagVal payloadtag;
if (pkgidp) if (pkgidp)
@ -377,13 +376,11 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
* such a package. * such a package.
*/ */
if (pkg->cpioArchiveSize < UINT32_MAX) { if (pkg->cpioArchiveSize < UINT32_MAX) {
sizetag = RPMSIGTAG_SIZE;
payloadtag = RPMSIGTAG_PAYLOADSIZE; payloadtag = RPMSIGTAG_PAYLOADSIZE;
} else { } else {
sizetag = RPMSIGTAG_LONGSIZE;
payloadtag = RPMSIGTAG_LONGARCHIVESIZE; payloadtag = RPMSIGTAG_LONGARCHIVESIZE;
} }
(void) rpmGenDigest(sig, sigtarget, sizetag); (void) rpmGenDigest(sig, sigtarget, RPMSIGTAG_SIZE);
(void) rpmGenDigest(sig, sigtarget, RPMSIGTAG_MD5); (void) rpmGenDigest(sig, sigtarget, RPMSIGTAG_MD5);
if (SHA1) { if (SHA1) {

View File

@ -347,24 +347,24 @@ int rpmGenDigest(Header sigh, const char * file, rpmTagVal sigTag)
int ret = -1; /* assume failure. */ int ret = -1; /* assume failure. */
switch (sigTag) { switch (sigTag) {
case RPMSIGTAG_SIZE: { case RPMSIGTAG_SIZE:
rpm_off_t size; case RPMSIGTAG_LONGSIZE:
if (stat(file, &st) != 0) if (stat(file, &st) != 0)
break; break;
size = st.st_size; if (st.st_size>UINT32_MAX || sigTag==RPMSIGTAG_LONGSIZE) {
if (!sighdrPut(sigh, sigTag, RPM_INT32_TYPE, &size, 1)) rpm_loff_t size;
break; size = st.st_size;
ret = 0; if (!sighdrPut(sigh, RPMSIGTAG_LONGSIZE, RPM_INT64_TYPE, &size, 1))
} break; break;
case RPMSIGTAG_LONGSIZE: { ret = 0;
rpm_loff_t size; } else {
if (stat(file, &st) != 0) rpm_off_t size;
break; size = st.st_size;
size = st.st_size; if (!sighdrPut(sigh, RPMSIGTAG_SIZE, RPM_INT32_TYPE, &size, 1))
if (!sighdrPut(sigh, sigTag, RPM_INT64_TYPE, &size, 1)) break;
break; ret = 0;
ret = 0; }
} break; break;
case RPMSIGTAG_MD5: case RPMSIGTAG_MD5:
pktlen = 16; pktlen = 16;
pkt = xcalloc(pktlen, sizeof(*pkt)); pkt = xcalloc(pktlen, sizeof(*pkt));