[PATCH 05/11] xfsprogs: xfs_mdrestore: check bad read count in perform_restore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



fix error reported by coverity - Integer overflowed argument

also, add print incase of invalid read count to get more debug
information.

Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
---
 mdrestore/xfs_mdrestore.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
index 5764616..a87a091 100644
--- a/mdrestore/xfs_mdrestore.c
+++ b/mdrestore/xfs_mdrestore.c
@@ -93,6 +93,10 @@ perform_restore(
 	block_index = (__be64 *)((char *)metablock + sizeof(xfs_metablock_t));
 	block_buffer = (char *)metablock + block_size;
 
+	if (block_size < sizeof(tmb))
+		fatal("bad read count, block_size: %d, tmb size %d\n",
+				block_size, sizeof(tmb));
+
 	if (fread(block_index, block_size - sizeof(tmb), 1, src_f) != 1)
 		fatal("error reading from file: %s\n", strerror(errno));
 
-- 
1.7.9.5

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux