]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: make script header parser more pedantic
authorKarel Zak <kzak@redhat.com>
Fri, 10 Oct 2014 10:24:10 +0000 (12:24 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 10 Oct 2014 10:24:10 +0000 (12:24 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/script.c

index 556c032c90908ed6dd81940a4ce4e8d4039f7a33..298d64a269f3b9f4a6cd737f5824f748587fa310 100644 (file)
@@ -461,6 +461,17 @@ static int parse_header_line(struct fdisk_script *dp, char *s)
        ltrim_whitespace((unsigned char *) value);
        rtrim_whitespace((unsigned char *) value);
 
+       if (strcmp(name, "label") == 0) {
+               if (dp->cxt && !fdisk_get_label(dp->cxt, value))
+                       goto done;                      /* unknown label name */
+       } else if (strcmp(name, "unit") == 0) {
+               if (strcmp(value, "sectors") != 0)
+                       goto done;                      /* only "sectors" supported */
+       } else if (strcmp(name, "label-id") == 0) {
+               ;                                       /* whatever is posssible */
+       } else
+               goto done;                              /* unknown header */
+
        if (*name && *value)
                rc = fdisk_script_set_header(dp, name, value);
 done: