aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-09-30 23:08:37 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-09-30 23:08:37 +0200
commit5f0ae7a0626cbe70944c67065292cbb056d0a7c9 (patch)
tree6a239bb6085974cbcac6b6d5aa5231d3788b1cb4 /lib
parent8fa519dce4746f35c4ad20020e9cc884d3a2549b (diff)
SFTP: avoid downloading negative sizes!
It is still not clarified exactly why this happens, but libssh2 sometimes report a negative file size for the remote SFTP file and that deeply confuses libcurl (or crashes it) so this precaution is added to avoid badness. Reported by: Ernest Beinrohr Bug: http://curl.haxx.se/bug/view.cgi?id=3076430
Diffstat (limited to 'lib')
-rw-r--r--lib/ssh.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index 06fd43999..026212103 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -1911,9 +1911,12 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
data->req.maxdownload = -1;
}
else {
- curl_off_t size;
+ curl_off_t size = attrs.filesize;
- size = attrs.filesize;
+ if(size < 0) {
+ failf(data, "Bad file size (%" FORMAT_OFF_T ")", size);
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
if(conn->data->state.use_range) {
curl_off_t from, to;
char *ptr;