[PATCH 1/4] btrfs-progs: check sscanf return code

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

 



coverity warned that the return code from sscanf() assigned to 'i'
wasn't checked before being assigned again.  Check it.

Signed-off-by: Zach Brown <zab@xxxxxxxxx>
---
 utils.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/utils.c b/utils.c
index c2f30d4..51e55be 100644
--- a/utils.c
+++ b/utils.c
@@ -1574,7 +1574,11 @@ scan_again:
 
 	strcpy(fullpath,"/dev/");
 	while(fgets(buf, 1023, proc_partitions)) {
-		i = sscanf(buf," %*d %*d %*d %99s", fullpath+5);
+		ret = sscanf(buf," %*d %*d %*d %99s", fullpath+5);
+		if (ret != 1) {
+			fprintf(stderr, "failed to scan device name from /proc/partitions\n");
+			break;
+		}
 
 		/*
 		 * multipath and MD devices may register as a btrfs filesystem
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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

  Powered by Linux