summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorZach Brown <zab@zabbo.net>2014-10-15 16:14:18 -0700
committerDavid Sterba <dsterba@suse.cz>2014-10-16 13:38:26 +0200
commit17063426a025dae59446a63388d0fb257d546192 (patch)
tree9e8407c7fa0959bfd7b07dccd51f838c1ae7249e /utils.c
parentbdac35cea24d11d3bcb6682038f907ba05484525 (diff)
btrfs-progs: check sscanf return code
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> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/utils.c b/utils.c
index b65eef70..5a72f19f 100644
--- a/utils.c
+++ b/utils.c
@@ -1579,7 +1579,12 @@ 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