]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Work around rpm bug if HEADERIMPORT_FAST is used
authorMichael Schroeder <mls@suse.de>
Mon, 19 Feb 2018 10:51:44 +0000 (11:51 +0100)
committerMichael Schroeder <mls@suse.de>
Mon, 19 Feb 2018 10:51:44 +0000 (11:51 +0100)
With HEADERIMPORT_FAST, rpm uses the difference between offsets
to determine the entry length. Unfortunately, the length is
used as entry count for RPM_BIN_TYPE, so the cound may end up
to big. So trim it again to match the md5 length.

Thanks to Oleg Girko <ol@infoserver.lv> for investigating this.

ext/repo_rpmdb.c

index ee226e70977e770b73f0d1a3b54668230b2789a3..cd14a9b4946ee1b1b0b5778e6a185f9979e49732 100644 (file)
@@ -446,7 +446,12 @@ headstringarray(RpmHead *h, int tag, int *cnt)
 static unsigned char *
 headbinary(RpmHead *h, int tag, unsigned int *sizep)
 {
-  return headget(h, tag, (int *)sizep, 0);
+  unsigned char *b = headget(h, tag, (int *)sizep, 0);
+  if (b && sizep && (tag == TAG_SIGMD5 || tag == SIGTAG_MD5) && *sizep > 16) {
+    /* due to a bug in rpm the count may be bigger if HEADERIMPORT_FAST is used */
+    *sizep = 16;
+  }
+  return b;
 }
 
 static int