Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdini...@redhat.com>
---
:100644 100644 20a77f2... 6bbf311... M  cman/qdisk/scandisk.c
 cman/qdisk/scandisk.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/cman/qdisk/scandisk.c b/cman/qdisk/scandisk.c
index 20a77f2..6bbf311 100644
--- a/cman/qdisk/scandisk.c
+++ b/cman/qdisk/scandisk.c
@@ -260,8 +260,10 @@ static int scanprocpart(struct devlisthead *devlisthead)
 
                if (strlen(line) > 128 + (22))
                        continue;
-               sscanf(line, "%4d %4d %10llu %s",
-                      &major, &minor, &blkcnt, device);
+
+               if (sscanf(line, "%4d %4d %10llu %s",
+                      &major, &minor, &blkcnt, device) < 4)
+                       continue;
 
                /* careful here.. if there is no device, we are scanning the
                 * first two lines that are not useful to us
@@ -327,8 +329,9 @@ static int scanmdstat(struct devlisthead *devlisthead)
                if (!(line[0] == 'm' && line[1] == 'd'))
                        continue;
 
-               sscanf(line, "%s %s %s %s %s",
-                      device, separator, status, personality, firstdevice);
+               if (sscanf(line, "%s %s %s %s %s",
+                      device, separator, status, personality, firstdevice) < 5)
+                       continue;
 
                /* scan only raids that are active */
                if (strcmp(status, "active"))
@@ -408,7 +411,8 @@ static int scanmapper(struct devlisthead *devlisthead)
                if (!start)
                        continue;
 
-               sscanf(line, "%s %s", major, device);
+               if (sscanf(line, "%s %s", major, device) < 2)
+                       continue;
 
                if (!strncmp(device, "device-mapper", 13)) {
                        maj = atoi(major);
-- 
1.7.4.4

Reply via email to