1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-28 11:55:23 +03:00

unit-name: Fix unescaping

Invalid characters in unit names are escaped as \xFF. However, when
unescaping we were looking for \FF.
This commit is contained in:
Tom Gundersen 2010-10-17 00:11:23 +02:00 committed by Lennart Poettering
parent abe35cc2b7
commit 95e501f8ab

View File

@ -272,13 +272,13 @@ char *unit_name_unescape(const char *f) {
else if (*f == '\\') {
int a, b;
if ((a = unhexchar(f[1])) < 0 ||
(b = unhexchar(f[2])) < 0) {
/* Invalid escape code, let's take it literal then */
if (f[1] != 'x' || (a = unhexchar(f[2])) < 0 ||
(b = unhexchar(f[3])) < 0) {
/* Invalid escape code, let's take it literal then */
*(t++) = '\\';
} else {
*(t++) = (char) ((a << 4) | b);
f += 2;
f += 3;
}
} else
*(t++) = *f;