teknoraver / rpms / rpm

Forked from rpms/rpm 5 months ago
Clone

Blame 0001-Skip-to-hashed-subpacket-data-directly.patch

Michal Domonkos ad0cd9
From f6ffaacbbf7f5aca45139a612c5dd8db3f2094dc Mon Sep 17 00:00:00 2001
Michal Domonkos b08229
From: Michal Domonkos <mdomonko@redhat.com>
Michal Domonkos b08229
Date: Mon, 5 Aug 2024 14:40:57 +0200
Michal Domonkos b08229
Subject: [PATCH] Skip to hashed subpacket data directly
Michal Domonkos b08229
Michal Domonkos ad0cd9
Let OpenScanHub grok the bigger picture instead of producing a spurious
Michal Domonkos ad0cd9
overrun warning for v->hashlen when we're dereferencing p later.
Michal Domonkos ad0cd9
Michal Domonkos ad0cd9
Casting the v pointer back to uint8_t is unnecessary when we could just
Michal Domonkos ad0cd9
use h directly but it's done this way in the if branch for pgp version 3
Michal Domonkos ad0cd9
in this function as well as in pgpPrtKey() so copy that, just for the
Michal Domonkos ad0cd9
sake of consistency.
Michal Domonkos ad0cd9
Michal Domonkos ad0cd9
Along the same lines (consistency), change the p pointer to a const
Michal Domonkos ad0cd9
pointer.
Michal Domonkos b08229
Michal Domonkos b08229
No functional change.
Michal Domonkos b08229
Michal Domonkos b08229
Resolves: RHEL-22607
Michal Domonkos b08229
---
Michal Domonkos ad0cd9
 rpmio/rpmpgp.c | 5 ++---
Michal Domonkos ad0cd9
 1 file changed, 2 insertions(+), 3 deletions(-)
Michal Domonkos b08229
Michal Domonkos b08229
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
Michal Domonkos ad0cd9
index d0688ebe9..6f044eb1b 100644
Michal Domonkos b08229
--- a/rpmio/rpmpgp.c
Michal Domonkos b08229
+++ b/rpmio/rpmpgp.c
Michal Domonkos ad0cd9
@@ -565,7 +565,7 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen,
Michal Domonkos ad0cd9
 		     pgpDigParams _digp)
Michal Domonkos ad0cd9
 {
Michal Domonkos ad0cd9
     uint8_t version = 0;
Michal Domonkos ad0cd9
-    uint8_t * p;
Michal Domonkos ad0cd9
+    const uint8_t * p;
Michal Domonkos ad0cd9
     unsigned int plen;
Michal Domonkos ad0cd9
     int rc = 1;
Michal Domonkos ad0cd9
 
Michal Domonkos b08229
@@ -618,10 +618,9 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen,
Michal Domonkos b08229
 	pgpPrtVal(" ", pgpSigTypeTbl, v->sigtype);
Michal Domonkos b08229
 	pgpPrtNL();
Michal Domonkos b08229
 
Michal Domonkos b08229
-	p = &v->hashlen[0];
Michal Domonkos b08229
 	if (pgpGet(v->hashlen, sizeof(v->hashlen), h + hlen, &plen))
Michal Domonkos b08229
 	    return 1;
Michal Domonkos b08229
-	p += sizeof(v->hashlen);
Michal Domonkos ad0cd9
+	p = ((uint8_t *)v) + sizeof(*v);
Michal Domonkos b08229
 
Michal Domonkos b08229
 	if ((p + plen) > (h + hlen))
Michal Domonkos b08229
 	    return 1;
Michal Domonkos b08229
-- 
Michal Domonkos ad0cd9
2.46.0
Michal Domonkos b08229