xfs_repair: resolve Coverity OVERFLOW_BEFORE_WIDEN
PATCH 1/1 xfs_repair: resolve Coverity OVERFLOW_BEFORE_WIDEN
Coverity complains that when multiplying two 32 bit values that eventually will be stored in a 64 bit value that it's possible the math could overflow unless one of the values being multiplied is type cast to the proper size.
--- repair/sb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
repair/sb.c +1 -1
@@ -230,7 +230,7 @@ find_secondary_sb(xfs_sb_t *rsb)do_warn (_ ("\nattempting to find secondary superblock...\n" ));if (verify_sb_blocksize (rsb) ==0 ) { - skip = rsb->sb_agblocks * rsb->sb_blocksize; + skip = (__uint64_t )rsb->sb_agblocks * rsb->sb_blocksize;if (skip >=XFS_AG_MIN_BYTES && skip <=XFS_AG_MAX_BYTES ) retval =__find_secondary_sb (rsb, skip, skip); }
Signature · 6 lines
2.7.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines · Bill O'Donnell
Coverity complains that when multiplying two 32 bit values that eventually will be stored in a 64 bit value that it's possible the math could overflow unless one of the values being multiplied is type cast to the proper size.
Signed-off-by Bill O'Donnell <[email protected]>
Makes sense. Given that this is repair, and either value could be larger than expected, we need the skip value to be accurate.
Quoted 10 lines
--- repair/sb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)repair/sb.c +0
-0
repair/sb.c find_secondary_sb(xfs_sb_t *rsb) · line 236
Quoted 8 lines
repair/sb.c +1
-1@@ -230,7 +230,7 @@ find_secondary_sb(xfs_sb_t *rsb)do_warn (_ ("\nattempting to find secondary superblock...\n" ));if (verify_sb_blocksize (rsb) ==0 ) { - skip = rsb->sb_agblocks * rsb->sb_blocksize; + skip = (__uint64_t )rsb->sb_agblocks * rsb->sb_blocksize;if (skip >=XFS_AG_MIN_BYTES && skip <=XFS_AG_MAX_BYTES ) retval =__find_secondary_sb (rsb, skip, skip); }
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs