]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: use \x<hex> to read/write partition name
authorKarel Zak <kzak@redhat.com>
Wed, 4 Jul 2018 12:06:38 +0000 (14:06 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Jul 2018 14:15:29 +0000 (16:15 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/656
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/script.c

index 972631cda5243beeae73b1ba067b95b6ce523209..d0eb0667e2a540a7afa9db280d6d7410b13113a8 100644 (file)
@@ -2,6 +2,7 @@
 #include "fdiskP.h"
 #include "strutils.h"
 #include "carefulputc.h"
+#include "mangle.h"
 
 /**
  * SECTION: script
@@ -650,8 +651,10 @@ static int write_file_sfdisk(struct fdisk_script *dp, FILE *f)
 
                if (pa->uuid)
                        fprintf(f, ", uuid=%s", pa->uuid);
-               if (pa->name && *pa->name)
-                       fprintf(f, ", name=\"%s\"", pa->name);
+               if (pa->name && *pa->name) {
+                       fputs(", name=", f);
+                       fputs_quoted(pa->name, f);
+               }
 
                /* for MBR attr=80 means bootable */
                if (pa->attrs) {
@@ -948,6 +951,7 @@ 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);
 
                } else if (!strncasecmp(p, "type=", 5) ||
                           !strncasecmp(p, "Id=", 3)) {         /* backward compatibility */