- Skip ghost files in payload (#1156497)

- Fix size and archice size tag generation on big-endian systems
This commit is contained in:
Panu Matilainen 2014-10-28 11:19:13 +02:00
parent 96d48126ff
commit 3feadd7134
3 changed files with 124 additions and 1 deletions

View File

@ -0,0 +1,76 @@
commit 104856ea17161eb3a508913c2b7ed701f2e4f6aa
Author: Panu Matilainen <pmatilai@redhat.com>
Date: Tue Oct 7 15:37:21 2014 +0300
Unbreak size and archive size generation on big-endian systems
- Fix regression from commit 68bddc353a7ea87ea00ad957858cd509e845e84c,
accessing a 64bit int as if it were a 32bit one doesn't make it one.
diff --git a/build/pack.c b/build/pack.c
index 28834dc..15f005a 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -273,9 +273,6 @@ static rpmRC generateSignature(char *SHA1, uint8_t *MD5, rpm_loff_t size,
{
Header sig = NULL;
struct rpmtd_s td;
- rpmTagVal sizetag;
- rpmTagVal payloadtag;
- rpm_tagtype_t typetag;
rpmRC rc = RPMRC_OK;
char *reservedSpace;
int spaceSize = 0;
@@ -297,29 +294,33 @@ static rpmRC generateSignature(char *SHA1, uint8_t *MD5, rpm_loff_t size,
td.data = MD5;
headerPut(sig, &td, HEADERPUT_DEFAULT);
+ rpmtdReset(&td);
+ td.count = 1;
if (payloadSize < UINT32_MAX) {
- sizetag = RPMSIGTAG_SIZE;
- payloadtag = RPMSIGTAG_PAYLOADSIZE;
- typetag = RPM_INT32_TYPE;
+ rpm_off_t p = payloadSize;
+ rpm_off_t s = size;
+ td.type = RPM_INT32_TYPE;
+
+ td.tag = RPMSIGTAG_PAYLOADSIZE;
+ td.data = &p;
+ headerPut(sig, &td, HEADERPUT_DEFAULT);
+
+ td.tag = RPMSIGTAG_SIZE;
+ td.data = &s;
+ headerPut(sig, &td, HEADERPUT_DEFAULT);
} else {
- sizetag = RPMSIGTAG_LONGSIZE;
- payloadtag = RPMSIGTAG_LONGARCHIVESIZE;
- typetag = RPM_INT64_TYPE;
- }
+ rpm_loff_t p = payloadSize;
+ rpm_loff_t s = size;
+ td.type = RPM_INT64_TYPE;
- rpmtdReset(&td);
- td.tag = payloadtag;
- td.count = 1;
- td.type = typetag;
- td.data = &payloadSize;
- headerPut(sig, &td, HEADERPUT_DEFAULT);
+ td.tag = RPMSIGTAG_LONGARCHIVESIZE;
+ td.data = &p;
+ headerPut(sig, &td, HEADERPUT_DEFAULT);
- rpmtdReset(&td);
- td.tag = sizetag;
- td.count = 1;
- td.type = typetag;
- td.data = &size;
- headerPut(sig, &td, HEADERPUT_DEFAULT);
+ td.tag = RPMSIGTAG_LONGSIZE;
+ td.data = &s;
+ headerPut(sig, &td, HEADERPUT_DEFAULT);
+ }
spaceSize = rpmExpandNumeric("%{__gpg_reserved_space}");
if(spaceSize > 0) {

View File

@ -0,0 +1,39 @@
diff --git a/lib/rpmarchive.h b/lib/rpmarchive.h
index fab2d58..85079ca 100644
--- a/lib/rpmarchive.h
+++ b/lib/rpmarchive.h
@@ -23,6 +23,7 @@ enum rpmfilesErrorCodes {
RPMERR_ENOENT = -10,
RPMERR_ENOTEMPTY = -11,
RPMERR_FILE_SIZE = -12,
+ RPMERR_ITER_SKIP = -13,
RPMERR_OPEN_FAILED = -32768,
RPMERR_CHMOD_FAILED = -32769,
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
index 384a6c9..2fba707 100644
--- a/lib/rpmfi.c
+++ b/lib/rpmfi.c
@@ -821,7 +821,10 @@ int rpmfiNext(rpmfi fi)
{
int next = -1;
if (fi != NULL) {
- next = fi->next(fi);
+ do {
+ next = fi->next(fi);
+ } while (next == RPMERR_ITER_SKIP);
+
if (next >= 0 && next < rpmfilesFC(fi->files)) {
fi->i = next;
fi->j = rpmfilesDI(fi->files, fi->i);
@@ -1942,6 +1945,10 @@ static int iterReadArchiveNext(rpmfi fi)
rpm_loff_t fsize = 0;
rpm_mode_t mode = rpmfilesFMode(fi->files, fx);
+ /* %ghost in payload, should not be there but rpm < 4.11 sometimes did this */
+ if (rpmfilesFFlags(fi->files, fx) & RPMFILE_GHOST)
+ return RPMERR_ITER_SKIP;
+
if (S_ISREG(mode)) {
const int * links;
uint32_t numlinks = rpmfilesFLinks(fi->files, fx, &links);

View File

@ -27,7 +27,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}2%{?dist}
Release: %{?snapver:0.%{snapver}.}3%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2
@ -52,6 +52,10 @@ Patch5: rpm-4.12.0-rpm2cpio-hack.patch
# Patches already upstream:
# Dont wait for transaction lock inside scriptlets (#1135596)
Patch100: rpm-4.12.0-tslock-nowait.patch
# Skip ghosts in payload (#1156497)
Patch101: rpm-4.12.0-payload-ghost.patch
# Unbreak size tag generation on big-endian systems
Patch102: rpm-4.12.0-archive-endian.patch
# These are not yet upstream
Patch302: rpm-4.7.1-geode-i686.patch
@ -530,6 +534,10 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Tue Oct 28 2014 Panu Matilainen <pmatilai@redhat.com> - 4.12.0.1-3
- Skip ghost files in payload (#1156497)
- Fix size and archice size tag generation on big-endian systems
* Wed Oct 01 2014 Panu Matilainen <pmatilai@redhat.com> - 4.12.0.1-2
- Dont wait for transaction lock inside scriptlets (#1135596)