]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
eject: robust strings usage [coverity scan]
authorKarel Zak <kzak@redhat.com>
Fri, 7 Sep 2012 11:43:36 +0000 (13:43 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 7 Sep 2012 11:43:56 +0000 (13:43 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/eject.c

index 2097961ef2c859fda6bd78d188a296e83bb3253c..1a5b834096b4a4d5182f5dc7d3c1d163fdc18563 100644 (file)
@@ -501,7 +501,7 @@ static int read_speed(const char *devname)
 
        name = rindex(devname, '/') + 1;
 
-       while (!feof(f)) {
+       while (name && !feof(f)) {
                char line[512];
                char *str;
 
@@ -513,7 +513,7 @@ static int read_speed(const char *devname)
                        if (strncmp(line, "drive name:", 11) == 0) {
                                str = strtok(&line[11], "\t ");
                                drive_number = 0;
-                               while (strncmp(name, str, strlen(name)) != 0) {
+                               while (str && strncmp(name, str, strlen(name)) != 0) {
                                        drive_number++;
                                        str = strtok(NULL, "\t ");
                                        if (!str)