From d000c03eed2eee3838792cd7a177c40f7e941a79 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Mon, 19 Feb 2018 11:51:44 +0100 Subject: [PATCH] Work around rpm bug if HEADERIMPORT_FAST is used 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 for investigating this. --- ext/repo_rpmdb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c index ee226e70..cd14a9b4 100644 --- a/ext/repo_rpmdb.c +++ b/ext/repo_rpmdb.c @@ -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 -- 2.47.2