diff options
| author | Karel Zak <kzak@redhat.com> | 2025-09-03 10:54:06 +0200 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2025-09-03 10:54:06 +0200 |
| commit | 4eab9175dfd62c1d1a0bbc43a49ca8a85e9adac7 (patch) | |
| tree | 6bfe28c5d81cdebee9b824c77cf7093008278cf4 /libfdisk/src/script.c | |
| parent | 0c57a76da61e5ab1f15eada0553b2ef85026269c (diff) | |
| download | util-linux-4eab9175dfd62c1d1a0bbc43a49ca8a85e9adac7.tar.gz | |
libfdisk: (script) fix device name separator parsing
In the named-fields script format, the colon is used as the separator
between the device name and other values. The device name may also
contain colons. This commit ensures it is treated as a separator only
when there is a space before or after the colon.
Note that the device name is optional and may be omitted. There is no
escaping for problematic characters in the name. Use " : " as the
separator.
Fixes: https://github.com/util-linux/util-linux/issues/3723
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/script.c')
| -rw-r--r-- | libfdisk/src/script.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c index e782f37c54..098a42f25d 100644 --- a/libfdisk/src/script.c +++ b/libfdisk/src/script.c @@ -1147,7 +1147,14 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s) fdisk_partition_partno_follow_default(pa, 1); /* set partno */ - p = strchr(s, ':'); + p = strstr(s, " : "); /* device : start= */ + if (!p) + p = strstr(s, " :"); /* device :start= */ + if (!p) + p = strstr(s, ": "); /* device: start= */ + if (!p) + p = strchr(s, ':'); + x = strchr(s, '='); if (p && (!x || p < x)) { *p = '\0'; @@ -1158,6 +1165,8 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s) fdisk_partition_partno_follow_default(pa, 0); fdisk_partition_set_partno(pa, pno); } + if (*p == ':') + p++; } else p = s; |
