git: 7a7324d9cebe - stable/13 - usr.bin/diff: fix UBSan error in readhash
Alex Richardson
arichardson at FreeBSD.org
Thu Aug 5 09:25:47 UTC 2021
The branch stable/13 has been updated by arichardson:
URL: https://cgit.FreeBSD.org/src/commit/?id=7a7324d9cebee6f42d77a39f3a8c657e23676cc2
commit 7a7324d9cebee6f42d77a39f3a8c657e23676cc2
Author: Alex Richardson <arichardson at FreeBSD.org>
AuthorDate: 2021-07-06 11:16:40 +0000
Commit: Alex Richardson <arichardson at FreeBSD.org>
CommitDate: 2021-08-05 08:59:26 +0000
usr.bin/diff: fix UBSan error in readhash
UBSan complains about the `sum = sum * 127 + chrtran(t);` line below since
that can overflow an `int`. Use `unsigned int` instead to ensure that
overflow is well-defined.
Reviewed By: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31075
(cherry picked from commit c78f449d85e0b292fe5d942cca99f11c1cd430fa)
---
usr.bin/diff/diffreg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 1b28281024c6..651ec88df909 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1345,7 +1345,7 @@ static int
readhash(FILE *f, int flags)
{
int i, t, space;
- int sum;
+ unsigned sum;
sum = 1;
space = 0;
More information about the dev-commits-src-all
mailing list