1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

archive: fix panic if len(source) < len(m)

Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
This commit is contained in:
Johan Euphrosine 2014-05-16 12:47:50 -07:00
parent 3118952e0a
commit 67ce59a806

View file

@ -47,6 +47,10 @@ func DetectCompression(source []byte) Compression {
Gzip: {0x1F, 0x8B, 0x08}, Gzip: {0x1F, 0x8B, 0x08},
Xz: {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00}, Xz: {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00},
} { } {
if len(source) < len(m) {
utils.Debugf("Len too short")
continue
}
if bytes.Compare(m, source[:len(m)]) == 0 { if bytes.Compare(m, source[:len(m)]) == 0 {
return compression return compression
} }