FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 11-23-2011, 09:15 AM
"Fabio M. Di Nitto"
 
Default qdiskd: check for sscanf return codes

Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@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
 

Thread Tools




All times are GMT. The time now is 09:25 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org