]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (script) fix segmentation fault
authorGaël PORTAY <gael.portay@collabora.com>
Fri, 20 Mar 2020 20:10:35 +0000 (16:10 -0400)
committerKarel Zak <kzak@redhat.com>
Fri, 15 May 2020 09:58:32 +0000 (11:58 +0200)
This patch fixes a segmentation fault that occurs if the name value is
empty (i.e. name=).

Signed-off-by: Gaël PORTAY <gael.portay@collabora.com>
libfdisk/src/script.c

index 6f66f88b948d47574c92554eebf3850c225986eb..8a27c6d79825a18be7bc916f7a3e11ae1b1bdbf4 100644 (file)
@@ -1057,7 +1057,8 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s)
                } else if (!strncasecmp(p, "name=", 5)) {
                        p += 5;
                        rc = next_string(&p, &pa->name);
-                       unhexmangle_string(pa->name);
+                       if (!rc)
+                               unhexmangle_string(pa->name);
 
                } else if (!strncasecmp(p, "type=", 5) ||
                           !strncasecmp(p, "Id=", 3)) {         /* backward compatibility */