From: Karel Zak Date: Fri, 1 Dec 2023 10:10:50 +0000 (+0100) Subject: libmount: fix fsconfig value unescaping X-Git-Tag: v2.40-rc1~142 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=608d4840f8f191529108fc2bdc0dd3dcb4bb7ab8;p=thirdparty%2Futil-linux.git libmount: fix fsconfig value unescaping Signed-off-by: Karel Zak --- diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c index 7143450fb7..961cc8745d 100644 --- a/libmount/src/hook_mount.c +++ b/libmount/src/hook_mount.c @@ -150,22 +150,29 @@ static inline int fsconfig_set_value( const char *name, const char *value) { int rc; - char *p = NULL; + char *s = NULL; + /* "\," is a way to use comma in values, let's remove \ escape */ if (value && strstr(value, "\\,")) { - p = strdup(value); - if (!p) - return -EINVAL; + char *x, *p; - strrem(p, '\\'); - value = p; + s = strdup(value); + if (!s) + return -EINVAL; + for (x = p = s; *x; p++, x++) { + if (*x == '\\' && *(x + 1) == ',') + x++; + *p = *x; + } + *p = '\0'; + value = s; } DBG(HOOK, ul_debugobj(hs, " fsconfig(name=\"%s\" value=\"%s\")", name, value ? : "")); if (value) { rc = fsconfig(fd, FSCONFIG_SET_STRING, name, value, 0); - free(p); + free(s); } else rc = fsconfig(fd, FSCONFIG_SET_FLAG, name, NULL, 0);