summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/script.c
diff options
context:
space:
mode:
authorKarel Zak2014-10-10 12:24:10 +0200
committerKarel Zak2014-10-10 12:24:10 +0200
commit2d2cb0251d021e9a7a9c9584d33d223e74096f1a (patch)
tree742cdff0c9e0e58854f63bf661a2691f184954c9 /libfdisk/src/script.c
parenttests: test cazy sizes for sfdisk (diff)
downloadkernel-qcow2-util-linux-2d2cb0251d021e9a7a9c9584d33d223e74096f1a.tar.gz
kernel-qcow2-util-linux-2d2cb0251d021e9a7a9c9584d33d223e74096f1a.tar.xz
kernel-qcow2-util-linux-2d2cb0251d021e9a7a9c9584d33d223e74096f1a.zip
libfdisk: make script header parser more pedantic
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/script.c')
-rw-r--r--libfdisk/src/script.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c
index 556c032c9..298d64a26 100644
--- a/libfdisk/src/script.c
+++ b/libfdisk/src/script.c
@@ -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: