summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2020-08-13 13:29:10 +0300
committerPanu Matilainen <pmatilai@redhat.com>2021-03-22 12:12:12 +0200
commitae835edf6d1843ce732cab87f37dae481bbb5b8f (patch)
treefc1ac29b143bf9fadbe9dc0dd923d774457dcda6
parent3e367defe17e2c1fa20548296c92d27b6d32ffde (diff)
downloadrpm-ae835edf6d1843ce732cab87f37dae481bbb5b8f.tar.gz
Work around buggy signature region preventing resigning (RhBug:1851508)
Various proprietary packages in the wild have subtly malformed data in the signature header, in particular wrt the immutable region size, presumably from using some in-house/3rd party signing tools which do not understand the immutable region business at all. This can prevent resigning and signature deletion on such packages due to the more thorough checking that rpmsign does. As the old wisdom goes, be liberal in what you accept... we can easily work around the crud by just taking a fresh copy of the contents that are legit as such (otherwise the package would be uninstallable). (cherry picked from commit 8fefd2bd21b30996ad0748eab6baadf915610642) (cherry picked from commit 04b0d37cadbdd6483d3454963ea8ad2d13602112)
-rw-r--r--sign/rpmgensig.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c
index 5be542001..fdc0be822 100644
--- a/sign/rpmgensig.c
+++ b/sign/rpmgensig.c
@@ -455,11 +455,19 @@ exit:
static void unloadImmutableRegion(Header *hdrp, rpmTagVal tag)
{
struct rpmtd_s td;
+ Header oh = NULL;
if (headerGet(*hdrp, tag, &td, HEADERGET_DEFAULT)) {
- Header oh = headerCopyLoad(td.data);
- Header nh = headerCopy(oh);
+ oh = headerCopyLoad(td.data);
rpmtdFreeData(&td);
+ } else {
+ /* XXX should we warn if the immutable region is corrupt/missing? */
+ oh = headerLink(*hdrp);
+ }
+
+ if (oh) {
+ /* Perform a copy to eliminate crud from buggy signing tools etc */
+ Header nh = headerCopy(oh);
headerFree(*hdrp);
*hdrp = headerLink(nh);
headerFree(nh);