]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix unmangle code
authorKarel Zak <kzak@redhat.com>
Mon, 13 Aug 2012 14:25:01 +0000 (16:25 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Aug 2012 14:35:03 +0000 (16:35 +0200)
old version:
  /mnt/ugly/te\134st\134 -> /mnt/ugly/te\st\134

fixed version:
  /mnt/ugly/te\134st\134 -> /mnt/ugly/te\st\

Reported-by: Naja Melan <najamelan@autistici.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/mangle.c

index faddeb879d11f1e66441d22b316f8311d6f44c36..2b18173618e125923ef6fdf09e643f9129fe55a0 100644 (file)
@@ -51,12 +51,13 @@ char *mangle(const char *s)
 void unmangle_to_buffer(const char *s, char *buf, size_t len)
 {
        size_t sz = 0;
+       char *x = buf;
 
        if (!s)
                return;
 
        while(*s && sz < len - 1) {
-               if (*s == '\\' && sz + 4 < len - 1 && isoctal(s[1]) &&
+               if (*s == '\\' && sz + 3 < len - 1 && isoctal(s[1]) &&
                    isoctal(s[2]) && isoctal(s[3])) {
 
                        *buf++ = 64*(s[1] & 7) + 8*(s[2] & 7) + (s[3] & 7);
@@ -78,7 +79,7 @@ void unhexmangle_to_buffer(const char *s, char *buf, size_t len)
                return;
 
        while(*s && sz < len - 1) {
-               if (*s == '\\' && sz + 4 < len - 1 && s[1] == 'x' &&
+               if (*s == '\\' && sz + 3 < len - 1 && s[1] == 'x' &&
                    isxdigit(s[2]) && isxdigit(s[3])) {
 
                        *buf++ = from_hex(s[2]) << 4 | from_hex(s[3]);