summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2016-05-06 14:14:19 +0000
committerAudrius Butkevicius <audrius.butkevicius@gmail.com>2016-05-06 14:14:19 +0000
commitdd5909568f21c5a4f1a281a2771b6566bfb242af (patch)
tree1662f4543624ffc207748a3eca332bb1a0b91b6e
parent38166e976f0b5e58c1192d6d070cf769a4193b0c (diff)
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
-rw-r--r--lib/upgrade/upgrade_supported.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/upgrade/upgrade_supported.go b/lib/upgrade/upgrade_supported.go
index ae63b48c3d..d4a05f4614 100644
--- a/lib/upgrade/upgrade_supported.go
+++ b/lib/upgrade/upgrade_supported.go
@@ -224,6 +224,11 @@ func readTarGz(archiveName, dir string, r io.Reader) (string, error) {
if err != nil {
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)
if err != nil {
@@ -264,6 +269,12 @@ func readZip(archiveName, dir string, r io.Reader) (string, error) {
}
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()
if err != nil {
return "", err