summaryrefslogtreecommitdiffstats
path: root/src/archive/zip/reader.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-08 04:10:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-08 04:10:35 +0000
commitda7e85e4b5d49867c08968d797a7e3bda779a58a (patch)
tree008413f15c1dd8ca9910433d1d089fb06d6ba17d /src/archive/zip/reader.go
parentAdding upstream version 1.22.3. (diff)
downloadgolang-1.22-da7e85e4b5d49867c08968d797a7e3bda779a58a.tar.xz
golang-1.22-da7e85e4b5d49867c08968d797a7e3bda779a58a.zip
Adding upstream version 1.22.4.upstream/1.22.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/archive/zip/reader.go')
-rw-r--r--src/archive/zip/reader.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go
index ff6fedf..60b34b7 100644
--- a/src/archive/zip/reader.go
+++ b/src/archive/zip/reader.go
@@ -699,9 +699,13 @@ func findSignatureInBlock(b []byte) int {
if b[i] == 'P' && b[i+1] == 'K' && b[i+2] == 0x05 && b[i+3] == 0x06 {
// n is length of comment
n := int(b[i+directoryEndLen-2]) | int(b[i+directoryEndLen-1])<<8
- if n+directoryEndLen+i <= len(b) {
- return i
+ if n+directoryEndLen+i > len(b) {
+ // Truncated comment.
+ // Some parsers (such as Info-ZIP) ignore the truncated comment
+ // rather than treating it as a hard error.
+ return -1
}
+ return i
}
}
return -1