lib/suitar: reject names ending in "/." or "/.."
diff --git a/doc/spec/suitar-spec.md b/doc/spec/suitar-spec.md index 1dca893..0a8525a 100644 --- a/doc/spec/suitar-spec.md +++ b/doc/spec/suitar-spec.md
@@ -86,7 +86,8 @@ - Names must not contain the `'\x7F'` ASCII DEL byte. - Names must be no longer than 4095 bytes, excluding a trailing NUL. - Names must not be `""`, `"."` or `".."`. -- Names must not start or end with `"/"`, `"./"` or `"../"`. +- Names must not start with `"/"`, `"./"` or `"../"`. +- Names must not end with `"/"`, `"/."` or `"/.."`. - Names must not contain `"//"`, `"/./"` or `"/../"` as substrings. For example, when converting from ZIP (with Japanese file names) to SUITAR, it
diff --git a/lib/suitar/suitar.go b/lib/suitar/suitar.go index 3a6212c..27ec692 100644 --- a/lib/suitar/suitar.go +++ b/lib/suitar/suitar.go
@@ -113,6 +113,8 @@ (name[len(name)-1] != '/') && !strings.HasPrefix(name, "./") && !strings.HasPrefix(name, "../") && + !strings.HasSuffix(name, "/.") && + !strings.HasSuffix(name, "/..") && !strings.Contains(name, "//") && !strings.Contains(name, "/./") && !strings.Contains(name, "/../") && @@ -208,9 +210,9 @@ } // Check the mode bits. - if (b[0x0068] == '6') && (b[0x0069] == '4') && (b[0x006A] == '4') { + if (b[0x068] == '6') && (b[0x069] == '4') && (b[0x06A] == '4') { // No-op. - } else if (b[0x0068] == '7') && (b[0x0069] == '5') && (b[0x006A] == '5') && (which == 1) { + } else if (b[0x068] == '7') && (b[0x069] == '5') && (b[0x06A] == '5') && (which == 1) { // No-op. } else { return false