]> 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)
committerGaël PORTAY <gael.portay@collabora.com>
Fri, 20 Mar 2020 20:28:33 +0000 (16:28 -0400)
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 e73c8dcdb1d2292322a956f50f6b30c3291722fc..cc53c3b7db5ca8cedfe090defcaa3579c127af6e 100644 (file)
@@ -1059,7 +1059,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 */