From 67ce59a806007cd28d96fd11208c4a113d1b92e0 Mon Sep 17 00:00:00 2001 From: Johan Euphrosine Date: Fri, 16 May 2014 12:47:50 -0700 Subject: [PATCH] archive: fix panic if len(source) < len(m) Docker-DCO-1.1-Signed-off-by: Johan Euphrosine (github: proppy) --- archive/archive.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/archive/archive.go b/archive/archive.go index c72849097..1eda6c2de 100644 --- a/archive/archive.go +++ b/archive/archive.go @@ -47,6 +47,10 @@ func DetectCompression(source []byte) Compression { Gzip: {0x1F, 0x8B, 0x08}, 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 { return compression }