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
This commit is contained in:
Alex Richardson
2021-07-06 12:16:40 +01:00
parent 31914882fc
commit c78f449d85
+1 -1
View File
@@ -1345,7 +1345,7 @@ static int
readhash(FILE *f, int flags)
{
int i, t, space;
int sum;
unsigned sum;
sum = 1;
space = 0;