ubi: fix false positive in volume_find
authorDaniel Golle <daniel@makrotopia.org>
Wed, 21 May 2014 02:42:29 +0000 (04:42 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 21 May 2014 02:42:29 +0000 (04:42 +0200)
An off-by-one made the string compare check only the string
length and not the terminating \0 which lead to rootfs being
found as rootfs_data.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
libfstools/ubi.c

index 42f76ca7a29a794cc9a2d968095f41c6b3e0f74b..3051720f65d8df6fc58848ff2422eae5d3c88d17 100644 (file)
@@ -138,7 +138,7 @@ static int ubi_volume_match(struct volume *v, char *name, int ubi_num, int volid
 
        volname = read_string_from_file(voldir, "name");
 
-       if (strncmp(name, volname, strlen(volname)))
+       if (strncmp(name, volname, strlen(volname) + 1))
                return -1;
 
        p = calloc(1, sizeof(struct ubi_priv));