michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 5 months ago
Clone

Blame SOURCES/0001-Fix-off-by-one-in-hdrblobGet-making-last-entry-unrea.patch

ed184b
From e219c9548d16a3c18dd261f7043bb8d221b87c77 Mon Sep 17 00:00:00 2001
ed184b
From: Panu Matilainen <pmatilai@redhat.com>
ed184b
Date: Wed, 31 Jul 2019 11:56:26 +0300
ed184b
Subject: [PATCH] Fix off-by-one in hdrblobGet() making last entry unreachable
ed184b
 (RhBug:1722921)
ed184b
ed184b
hdrblobGet() introduced in commits acfde0d0e812e9f8e153ab6be8c9f2682bdd4763
ed184b
and 9821de18811db97238c34a564221e315f5f35b44 has an off-by-one thinko
ed184b
(perhaps the idea was to skip the first, region tag) which causes
ed184b
the last entry to be unreachable. In typical packages, that is
ed184b
RPMSIG_PAYLOADSIZE which is not used at all in this context so it doesn't
ed184b
matter, but in large packages use RPMSIG_LONGARCHIVESIZE which has a lower
ed184b
tag number and leaves either RPMSIGTAG_MD5 or RPMSIGTAG_GPG last,
ed184b
unreachable and thus unverifiable. Oops.
ed184b
ed184b
This fixes the regression introduced in rpm 4.14, affecting verification
ed184b
of large packages (ie having RPMSIG_LONGARCHIVESIZE)
ed184b
---
ed184b
 lib/header.c | 2 +-
ed184b
 1 file changed, 1 insertion(+), 1 deletion(-)
ed184b
ed184b
diff --git a/lib/header.c b/lib/header.c
ed184b
index 33623884a..9ec7ed0e4 100644
ed184b
--- a/lib/header.c
ed184b
+++ b/lib/header.c
ed184b
@@ -2015,7 +2015,7 @@ rpmRC hdrblobGet(hdrblob blob, uint32_t tag, rpmtd td)
ed184b
     memset(&einfo, 0, sizeof(einfo));
ed184b
     rpmtdReset(td);
ed184b
 
ed184b
-    for (int i = 1; i < blob->il; i++, pe++) {
ed184b
+    for (int i = 0; i < blob->il; i++, pe++) {
ed184b
 	if (pe->tag != ntag)
ed184b
 	    continue;
ed184b
 	ei2h(pe, &einfo);
ed184b
-- 
ed184b
2.21.0
ed184b