summaryrefslogtreecommitdiff
path: root/lib/ssh.c
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2008-10-21 07:10:25 +0000
committerDan Fandrich <dan@coneharvesters.com>2008-10-21 07:10:25 +0000
commit7ff38c14a97e701a9ab521a3730b014c3647b14e (patch)
tree5666a2f2e6d3bb22b8e4d41da069c4572cef71b2 /lib/ssh.c
parent3f2de3d1019140571a59c04249de085a318f9266 (diff)
downloadcurl-7ff38c14a97e701a9ab521a3730b014c3647b14e.tar.gz
Fixed some problems with SFTP range support to fix test cases 634 through 637.
Diffstat (limited to 'lib/ssh.c')
-rw-r--r--lib/ssh.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index 005eb265f..19b685f30 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -1644,11 +1644,21 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-')))
ptr++;
to=curlx_strtoofft(ptr, &ptr2, 0);
- if ((ptr == ptr2) /* no "to" value given */
- || (to > size)) {
- to = size;
+ if((ptr == ptr2) /* no "to" value given */
+ || (to >= size)) {
+ to = size - 1;
}
- if (from > to) {
+ if(from < 0) {
+ /* from is relative to end of file */
+ from += size;
+ }
+ if(from >= size) {
+ failf(data, "Offset (%"
+ FORMAT_OFF_T ") was beyond file size (%" FORMAT_OFF_T ")",
+ from, attrs.filesize);
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
+ if(from > to) {
from = to;
size = 0;
}