summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-06-30 21:25:59 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-06-30 21:25:59 (GMT)
commit55008800e4e257ca3be55ae312fe6e94d6823d2a (patch)
tree5205d14431f7ad036fb60824e0b3ec35125b1dbc
parent656c8bd78bb60b4f1c49df9eaac206f56bcb6663 (diff)
limit maximum file size for downloads without max size
-rw-r--r--rhimport/fetcher.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go
index e398361..324ee5d 100644
--- a/rhimport/fetcher.go
+++ b/rhimport/fetcher.go
@@ -49,6 +49,7 @@ type FetcherCurlCBData struct {
filename string
remotename string
conv FetchConverter
+ written uint64
writeError error
}
@@ -86,11 +87,18 @@ func curlWriteCallback(ptr []byte, userdata interface{}) bool {
data.filename = newFilename
data.conv = conv
}
- if _, err := data.conv.Write(ptr); err != nil {
+ w, err := data.conv.Write(ptr)
+ if err != nil {
rhl.Printf("Unable to write to converter(%s): %s", data.filename, err)
data.writeError = err
return false
}
+ data.written += uint64(w)
+ if data.written > FILESIZE_MAX {
+ data.writeError = fmt.Errorf("file exceeds maximum file size")
+ return false
+ }
+
return true
}