xfs_spaceman: fix potential overflowing expression in trim_f()
PATCH 1/1 xfs_spaceman: fix potential overflowing expression in trim_f()
Prevent the potential overflow in expression calculating offset in trim_f(() by casting the first variable to off64_t (64bit signed).
Detected by CoverityScan, CID#1413771 Integer handling issues (OVERFLOW_BEFORE_WIDEN)
Signed-off-by Bill O'Donnell <[email protected]>
--- spaceman/trim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
spaceman/trim.c +1 -1
@@ -77,7 +77,7 @@ trim_f( length =cvtnum (file->geom.blocksize, file->geom.sectsize, argv[optind +1 ]); }else if (agno) { - offset = agno * file->geom.agblocks * file->geom.blocksize; + offset = (off64_t )agno * file->geom.agblocks * file->geom.blocksize; length = file->geom.agblocks * file->geom.blocksize; }else { offset =0 ;
Signature · 1 line
2.13.0
Quoted 6 lines · Bill O'Donnell
Prevent the potential overflow in expression calculating offset in trim_f(() by casting the first variable to
off64_t(64bit signed).Detected by CoverityScan, CID#1413771 Integer handling issues (
OVERFLOW_BEFORE_WIDEN)Signed-off-by Bill O'Donnell <[email protected]>
Reviewed-by Darrick J. Wong <[email protected]>
--D
Quoted 24 lines
--- spaceman/trim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)spaceman/trim.c +1
-1@@ -77,7 +77,7 @@ trim_f( length =cvtnum (file->geom.blocksize, file->geom.sectsize, argv[optind +1 ]); }else if (agno) { - offset = agno * file->geom.agblocks * file->geom.blocksize; + offset = (off64_t )agno * file->geom.agblocks * file->geom.blocksize; length = file->geom.agblocks * file->geom.blocksize; }else { offset =0 ;Signature · 6 lines
2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html