diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-05-06 23:30:59 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-05-06 23:30:59 (GMT) |
commit | 66ea4919ea172c126ea11d65441f7707d9e2cdac (patch) | |
tree | aeb772721ebcaa14bb5f1b3a3fabb16a64abac35 /rhimport | |
parent | f500c36ebcdbe77503e1c71fcac26b44be174039 (diff) |
fix handling of errernous files in curl urls
Diffstat (limited to 'rhimport')
-rw-r--r-- | rhimport/fetcher.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go index ff25ae3..b248483 100644 --- a/rhimport/fetcher.go +++ b/rhimport/fetcher.go @@ -75,7 +75,12 @@ func curlWriteCallback(ptr []byte, userdata interface{}) bool { data := userdata.(*FetcherCurlCBData) if data.file == nil { if data.filename == "" { - data.filename = filepath.Join(data.basepath, path.Clean("/"+data.remotename)) + name := path.Clean("/" + data.remotename) + if name == "/" { + rhdl.Printf("remotename('%s') is invalid, replacing it with 'unnamed'", data.remotename) + name = "unnamed" + } + data.filename = filepath.Join(data.basepath, name) } fp, err := os.OpenFile(data.filename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600) if err != nil { |