mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
lib/suitar: reject names ending in "/." or "/.."
This commit is contained in:
1 parent
5049107b90
commit
742e8b78d9
2 files changed
+6
-3
No files matched your search
@@ -86,7 +86,8 @@ These rules apply to both file names and directory names.
|
||||
- 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
|
||||
|
||||
@@ -113,6 +113,8 @@ func IsValidHeaderName(name string) bool {
|
||||
(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 @@ func (b *block) isValidHeader(which int) bool {
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in new issue
Block a user