lib/upgrade: Don't attempt processing files larger than expected max binary size (ref #3045)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3047
This commit is contained in:
Jakob Borg 2016-05-06 14:14:19 +00:00 committed by Audrius Butkevicius
parent 38166e976f
commit dd5909568f

View File

@ -224,6 +224,11 @@ func readTarGz(archiveName, dir string, r io.Reader) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
if hdr.Size > maxBinarySize {
// We don't even want to try processing or skipping over files
// that are too large.
break
}
err = archiveFileVisitor(dir, &tempName, &sig, hdr.Name, tr) err = archiveFileVisitor(dir, &tempName, &sig, hdr.Name, tr)
if err != nil { if err != nil {
@ -264,6 +269,12 @@ func readZip(archiveName, dir string, r io.Reader) (string, error) {
} }
i++ i++
if file.UncompressedSize64 > maxBinarySize {
// We don't even want to try processing or skipping over files
// that are too large.
break
}
inFile, err := file.Open() inFile, err := file.Open()
if err != nil { if err != nil {
return "", err return "", err