diff options
| author | Karel Zak <kzak@redhat.com> | 2023-11-28 14:40:48 +0100 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2023-11-28 14:40:48 +0100 |
| commit | f6c29efa929cb8c741591ab38061e7921d53a997 (patch) | |
| tree | 57ab61f487e42a007db54a753b964497a7fb0dbd /lib/strutils.c | |
| parent | 556dac801322edd60485bc45312523527d7e5fc2 (diff) | |
| download | util-linux-f6c29efa929cb8c741591ab38061e7921d53a997.tar.gz | |
libmount: accept '\' as escape for options separator
The libmount library can accept any characters as an option value when
the value is quoted (e.g., foo="b,a,r"). However, overlayfs users have
been using '\' as an escape character (e.g., lowerdir=foo\,bar).
Although this escaping mechanism was never officially supported by
libmount/mount, it worked for the old mount(2) API because it kept the
options string unparsed for the mount(2) syscall.
The introduction of the new mount API, which utilizes fsconfig(2) per
option, has brought attention to this issue.
This patch addresses the problem by introducing official support for
'\' as an escape character for options separator.
Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
References: https://lore.kernel.org/all/CAOQ4uxhgUSPkYAV8SJu-SFszkJcVO3-M4DXf46nJUtXODrPk2g@mail.gmail.com/T/#ma8e6cfc1ce7229abc089e03eed99b23b90d701e5
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/strutils.c')
| -rw-r--r-- | lib/strutils.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/strutils.c b/lib/strutils.c index 422f8e5807..9ea5da7cbc 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -1225,7 +1225,7 @@ int ul_optstr_next(char **optstr, char **name, size_t *namesz, continue; /* still in quoted block */ if (!sep && p > start && *p == '=') sep = p; /* name and value separator */ - if (*p == ',') + if (*p == ',' && (p == optstr0 || *(p - 1) != '\\')) stop = p; /* terminate the option item */ else if (*(p + 1) == '\0') stop = p + 1; /* end of optstr */ |
