diff mbox

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

Message ID 1413414861-28097-2-git-send-email-zab@zabbo.net (mailing list archive)
State Accepted
Headers show

Commit Message

Zach Brown Oct. 15, 2014, 11:14 p.m. UTC
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@zabbo.net>
---
 utils.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox

Patch

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