From c47faa21d46dab108f808f647742529b32a586bec72b87d816697a50c5070fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Fri, 5 Jan 2018 12:28:18 +0000 Subject: [PATCH] fix signature header writing if the archive size is bigger than 2G OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=429 --- bigarchive.diff | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ rpm.changes | 7 ++++++ rpm.spec | 3 ++- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 bigarchive.diff diff --git a/bigarchive.diff b/bigarchive.diff new file mode 100644 index 0000000..e449c45 --- /dev/null +++ b/bigarchive.diff @@ -0,0 +1,66 @@ +--- lib/signature.c.orig 2018-01-05 10:59:06.358348915 +0000 ++++ lib/signature.c 2018-01-05 12:25:13.224472739 +0000 +@@ -118,6 +118,8 @@ rpmRC rpmGenerateSignature(char *SHA256, + char *reservedSpace; + int spaceSize = 32; /* always reserve a bit of space */ + int gpgSize = rpmExpandNumeric("%{__gpg_reserved_space}"); ++ rpm_off_t size32 = size; ++ rpm_off_t payloadSize32 = payloadSize; + + /* Prepare signature */ + if (SHA256) { +@@ -149,21 +151,32 @@ rpmRC rpmGenerateSignature(char *SHA256, + + rpmtdReset(&td); + td.count = 1; +- if (payloadSize < UINT32_MAX) { +- rpm_off_t p = payloadSize; +- rpm_off_t s = size; +- td.type = RPM_INT32_TYPE; ++ td.type = RPM_INT32_TYPE; + +- td.tag = RPMSIGTAG_PAYLOADSIZE; +- td.data = &p; +- headerPut(sig, &td, HEADERPUT_DEFAULT); ++ td.tag = RPMSIGTAG_PAYLOADSIZE; ++ td.data = &payloadSize32; ++ headerPut(sig, &td, HEADERPUT_DEFAULT); + +- td.tag = RPMSIGTAG_SIZE; +- td.data = &s; +- headerPut(sig, &td, HEADERPUT_DEFAULT); +- } else { ++ td.tag = RPMSIGTAG_SIZE; ++ td.data = &size32; ++ headerPut(sig, &td, HEADERPUT_DEFAULT); ++ ++ if (payloadSize >= UINT32_MAX) { ++ /* ++ * Put the 64bit size variants into the header, but ++ * modify spaceSize so that the resulting header has ++ * the same size. Note that this only works if ++ * RPMSIGTAG_RESERVEDSPACE is the last tag in the header! ++ */ + rpm_loff_t p = payloadSize; + rpm_loff_t s = size; ++ int newsigSize, oldsigSize; ++ ++ oldsigSize = headerSizeof(sig, HEADER_MAGIC_YES); ++ ++ headerDel(sig, RPMSIGTAG_PAYLOADSIZE); ++ headerDel(sig, RPMSIGTAG_SIZE); ++ + td.type = RPM_INT64_TYPE; + + td.tag = RPMSIGTAG_LONGARCHIVESIZE; +@@ -174,8 +187,8 @@ rpmRC rpmGenerateSignature(char *SHA256, + td.data = &s; + headerPut(sig, &td, HEADERPUT_DEFAULT); + +- /* adjust for the size difference between 64- and 32bit tags */ +- spaceSize -= 8; ++ newsigSize = headerSizeof(sig, HEADER_MAGIC_YES); ++ spaceSize -= newsigSize - oldsigSize; + } + + if (gpgSize > 0) diff --git a/rpm.changes b/rpm.changes index 992fbbb..17ee250 100644 --- a/rpm.changes +++ b/rpm.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Jan 5 13:26:50 CET 2018 - mls@suse.de + +- fix signature header writing if the archive size is bigger + than 2 GByte + new patch: bigarchive.diff + ------------------------------------------------------------------- Tue Jan 2 11:04:52 CET 2018 - mls@suse.de diff --git a/rpm.spec b/rpm.spec index 8e91f18..8a85ea7 100644 --- a/rpm.spec +++ b/rpm.spec @@ -133,6 +133,7 @@ Patch106: transfiletriggerpostun.diff Patch107: hardlink.diff Patch108: debugedit-macro.diff Patch109: pythondistdeps.diff +Patch110: bigarchive.diff Patch6464: auto-config-update-aarch64-ppc64le.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build # @@ -229,7 +230,7 @@ rm -f rpmdb/db.h %patch -P 85 %patch -P 93 -P 94 -P 99 %patch -P 100 -P 102 -P 103 -P 104 -P 105 -P 106 -P 107 -P 108 -%patch -P 109 +%patch -P 109 -P 110 %ifarch aarch64 ppc64le %patch6464