chiark / gitweb /
service: prefix description with LSB only if script has LSB header, use 'SysV:' otherwise
[elogind.git] / src / unit-name.c
index d0cfca62549cb9af5329d7a84e491de355679903..be4e73edccb0e3ae5561977aea456564626c1d69 100644 (file)
@@ -213,7 +213,7 @@ char *unit_name_build_escape(const char *prefix, const char *instance, const cha
          * suffix and makes a nice string suitable as unit name of it,
          * escaping all weird chars on the way.
          *
-         * / becomes ., and all chars not alloweed in a unit name get
+         * / becomes ., and all chars not allowed in a unit name get
          * escaped as \xFF, including \ and ., of course. This
          * escaping is hence reversible.
          *
@@ -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;