mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-26 01:46:13 +01:00
validate received file length based on given Content-Length. for Bug #656281
This commit is contained in:
parent
94836bcbf7
commit
d3188831b9
12
osc/core.py
12
osc/core.py
@ -4495,12 +4495,13 @@ def streamfile(url, http_meth = http_GET, bufsize=8192, data=None, progress_obj=
|
||||
caller.
|
||||
"""
|
||||
f = http_meth.__call__(url, data = data)
|
||||
import urlparse
|
||||
cl = f.info().get('Content-Length')
|
||||
if cl is not None:
|
||||
cl = int(cl)
|
||||
|
||||
if progress_obj:
|
||||
import urlparse
|
||||
basename = os.path.basename(urlparse.urlsplit(url)[2])
|
||||
cl = f.info().get('Content-Length')
|
||||
if cl is not None:
|
||||
cl = int(cl)
|
||||
progress_obj.start(basename=basename, text=text, size=cl)
|
||||
data = f.read(bufsize)
|
||||
read = len(data)
|
||||
@ -4514,6 +4515,9 @@ def streamfile(url, http_meth = http_GET, bufsize=8192, data=None, progress_obj=
|
||||
progress_obj.end(read)
|
||||
f.close()
|
||||
|
||||
if read != cl:
|
||||
raise oscerr.OscIOError(None, ('Content-Length is not matching file size for %s: %i vs %i file size' % (url, cl, read)) )
|
||||
|
||||
|
||||
def print_buildlog(apiurl, prj, package, repository, arch, offset = 0):
|
||||
"""prints out the buildlog on stdout"""
|
||||
|
Loading…
Reference in New Issue
Block a user