[systemd-commits] src/unit-name.c

Lennart Poettering lennart at kemper.freedesktop.org
Thu Oct 21 05:04:40 PDT 2010


 src/unit-name.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 95e501f8ab28e1645453219523c0263754db3f68
Author: Tom Gundersen <teg at jklm.no>
Date:   Sun Oct 17 00:11:23 2010 +0200

    unit-name: Fix unescaping
    
    Invalid characters in unit names are escaped as \xFF. However, when
    unescaping we were looking for \FF.

diff --git a/src/unit-name.c b/src/unit-name.c
index d0cfca6..debf2b2 100644
--- a/src/unit-name.c
+++ b/src/unit-name.c
@@ -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;


More information about the systemd-commits mailing list