Forráskód Böngészése

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

Docker-DCO-1.1-Signed-off-by: Johan Euphrosine <proppy@google.com> (github: proppy)
Johan Euphrosine 11 éve
szülő
commit
67ce59a806
1 módosított fájl, 4 hozzáadás és 0 törlés
  1. 4 0
      archive/archive.go

+ 4 - 0
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
 		}