summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDemi Marie Obenour <demi@invisiblethingslab.com>2021-06-21 06:55:37 -0400
committerPanu Matilainen <pmatilai@redhat.com>2021-06-22 15:02:29 +0300
commit03b0a8241a6b5b5bf33bd220a163147b2e4c2f40 (patch)
tree6665864403a564ec3bbe0c0aaf03476239e6f1dc
parent4dd95c270ffe7bf6612d7cda5f6d5e833f0ab771 (diff)
downloadrpm-03b0a8241a6b5b5bf33bd220a163147b2e4c2f40.tar.gz
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. (cherry picked from commit 56917aaffe65978779129a294af7ddc0afc98f55)
-rw-r--r--lib/header.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/header.c b/lib/header.c
index 1a55cea15..2c3348ca7 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;
}