summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-09-17 15:47:08 -0400
committerDave Reisner <dreisner@archlinux.org>2013-09-17 16:31:32 -0400
commit22f5f6281fc25f43a85938e9dad2480b2595c471 (patch)
tree44701cb1a2ee05621feaad1f938eaa02c9ca299d /src/shared
parent02a36bc9a1769c744f141f127898dbe076dbfd96 (diff)
Use udev_encode_string in fstab_node_to_udev_node
Resolves a longstanding bug which caused this function to wrongly handle (escape) valid utf8 characters.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index f6f3b18bfc..2b76a5c885 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -73,6 +73,7 @@
#include "hashmap.h"
#include "env-util.h"
#include "fileio.h"
+#include "utf8.h"
int saved_argc = 0;
char **saved_argv = NULL;
@@ -3495,26 +3496,23 @@ int signal_from_string_try_harder(const char *s) {
}
static char *tag_to_udev_node(const char *tagvalue, const char *by) {
- char *dn, *t, *u;
- int r;
-
- /* FIXME: to follow udev's logic 100% we need to leave valid
- * UTF8 chars unescaped */
+ _cleanup_free_ char *t = NULL, *u = NULL;
+ char *dn;
+ size_t enc_len;
u = unquote(tagvalue, "\"\'");
if (u == NULL)
return NULL;
- t = xescape(u, "/ ");
- free(u);
-
+ enc_len = strlen(u) * 4;
+ t = new(char, enc_len);
if (t == NULL)
return NULL;
- r = asprintf(&dn, "/dev/disk/by-%s/%s", by, t);
- free(t);
+ if (udev_encode_string(u, t, enc_len) < 0)
+ return NULL;
- if (r < 0)
+ if (asprintf(&dn, "/dev/disk/by-%s/%s", by, t) < 0)
return NULL;
return dn;