From 072588ca7908ef894be4161066c9384edaadd748 Mon Sep 17 00:00:00 2001
From: Demi Marie Obenour <demi@invisiblethingslab.com>
Date: Thu, 17 Jun 2021 14:11:54 -0400
Subject: [PATCH] Reduce undefined pointer arithmetic

Conflict:NA
Reference:https://github.com/rpm-software-management/rpm/commit/072588ca7908ef894be4161066c9384edaadd748

---
 rpmio/rpmpgp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 436c46d..b174a40 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -520,9 +520,9 @@ static int pgpPrtSigParams(pgpTag tag, uint8_t pubkey_algo, uint8_t sigtype,
     int i;
     pgpDigAlg sigalg = pgpSignatureNew(pubkey_algo);
 
-    for (i = 0; i < sigalg->mpis && p + 2 <= pend; i++) {
+    for (i = 0; i < sigalg->mpis && pend - p >= 2; i++) {
 	int mpil = pgpMpiLen(p);
-	if (p + mpil > pend)
+	if (pend - p < mpil)
 	    break;
 	if (sigtype == PGPSIGTYPE_BINARY || sigtype == PGPSIGTYPE_TEXT) {
 	    if (sigalg->setmpi(sigalg, i, p))
-- 
2.27.0

