fix logic bug inside extroot uuid verification code
[project/fstools.git] / block.c
diff --git a/block.c b/block.c
index 33264583c23b91ef32747c5e50c0c7b4fb624283..2e95c033b53ba23b091498e396e2db41e9f0141a 100644 (file)
--- a/block.c
+++ b/block.c
@@ -592,13 +592,13 @@ static char* find_mount_point(char *block)
        int len = strlen(block);
        char *point = NULL, *pos, *tmp, *cpoint, *devname;
        struct stat s;
+       int rstat;
        unsigned int minor, major;
 
        if (!fp)
                return NULL;
 
-       if (stat(block, &s))
-               return NULL;
+       rstat = stat(block, &s);
 
        while (fgets(line, sizeof(line), fp)) {
                pos = strchr(line, ' ');
@@ -658,6 +658,9 @@ static char* find_mount_point(char *block)
                        break;
                }
 
+               if (rstat)
+                       continue;
+
                if (!S_ISBLK(s.st_mode))
                        continue;
 
@@ -1105,7 +1108,7 @@ static int check_extroot(char *path)
                                         tag, errno, strerror(errno));
                        fclose(fp);
 
-                       if (*uuid || !strcasecmp(uuid, pr->uuid))
+                       if (*uuid && !strcasecmp(uuid, pr->uuid))
                                return 0;
 
                        ULOG_ERR("extroot: UUID mismatch (root: %s, %s: %s)\n",