libfdisk: make script header parser more pedantic

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2014-10-10 12:24:10 +02:00
parent 9368018ff0
commit 2d2cb0251d
1 changed files with 11 additions and 0 deletions

View 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: