From 2786b99aa15d8de32337410bcf37c44652f89a5d Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Mon, 21 Jun 2021 06:55:37 -0400 Subject: [PATCH] Make a bounds check easier to read The undefined behavior is not an issue on modern GCC, but the new code is easier to read. --- lib/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/header.c b/lib/header.c index 1a55cea153..2c3348ca74 100644 --- a/lib/header.c +++ b/lib/header.c @@ -475,7 +475,7 @@ static int dataLength(rpm_tagtype_t type, rpm_constdata_t p, rpm_count_t count, if (typeSizes[type] == -1) return -1; length = typeSizes[(type & 0xf)] * count; - if (length < 0 || (se && (s + length) > se)) + if (length < 0 || (se && se - s < length)) return -1; break; }