extract.c: control characters are invalid in filenames on Windows
authorEric Biggers <ebiggers3@gmail.com>
Sun, 7 Jun 2015 14:38:19 +0000 (09:38 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 7 Jun 2015 18:28:43 +0000 (13:28 -0500)
src/extract.c

index 706282e..4f1c54a 100644 (file)
@@ -655,19 +655,20 @@ file_name_valid(utf16lechar *name, size_t num_chars, bool fix)
        if (num_chars == 0)
                return true;
        for (i = 0; i < num_chars; i++) {
-               switch (name[i]) {
+               switch (le16_to_cpu(name[i])) {
        #ifdef __WIN32__
-               case cpu_to_le16('\\'):
-               case cpu_to_le16(':'):
-               case cpu_to_le16('*'):
-               case cpu_to_le16('?'):
-               case cpu_to_le16('"'):
-               case cpu_to_le16('<'):
-               case cpu_to_le16('>'):
-               case cpu_to_le16('|'):
+               case '\x01'...'\x1F':
+               case '\\':
+               case ':':
+               case '*':
+               case '?':
+               case '"':
+               case '<':
+               case '>':
+               case '|':
        #endif
-               case cpu_to_le16('/'):
-               case cpu_to_le16('\0'):
+               case '/':
+               case '\0':
                        if (fix)
                                name[i] = replacement_char;
                        else