Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jul 2021 13:29:27 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: c78f449d85e0 - main - usr.bin/diff: fix UBSan error in readhash
Message-ID:  <202107061329.166DTRNj084355@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=c78f449d85e0b292fe5d942cca99f11c1cd430fa

commit c78f449d85e0b292fe5d942cca99f11c1cd430fa
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-07-06 11:16:40 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-07-06 11:16:40 +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
---
 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107061329.166DTRNj084355>