Skip to content

Commit 0754562

Browse files
amstewartevpobr
authored andcommitted
mat4/mat5: fix int overflow in dataend calculation
The clang sanitizer warns of a possible signed integer overflow when calculating the `dataend` value in `mat4_read_header()`. ``` src/mat4.c:323:41: runtime error: signed integer overflow: 205 * -100663296 cannot be represented in type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/mat4.c:323:41 in src/mat4.c:323:48: runtime error: signed integer overflow: 838860800 * 4 cannot be represented in type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/mat4.c:323:48 in ``` Cast the offending `rows` and `cols` ints to `sf_count_t` (the type of `dataend` before performing the calculation, to avoid the issue. CVE: CVE-2022-33065 Fixes: #789 Fixes: #833 Signed-off-by: Alex Stewart <alex.stewart@ni.com>
1 parent 95201af commit 0754562

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mat4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ mat4_read_header (SF_PRIVATE *psf)
320320
psf->filelength - psf->dataoffset, psf->sf.channels * psf->sf.frames * psf->bytewidth) ;
321321
}
322322
else if ((psf->filelength - psf->dataoffset) > psf->sf.channels * psf->sf.frames * psf->bytewidth)
323-
psf->dataend = psf->dataoffset + rows * cols * psf->bytewidth ;
323+
psf->dataend = psf->dataoffset + (sf_count_t) rows * (sf_count_t) cols * psf->bytewidth ;
324324

325325
psf->datalength = psf->filelength - psf->dataoffset - psf->dataend ;
326326

0 commit comments

Comments
 (0)