From 7ff38c14a97e701a9ab521a3730b014c3647b14e Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 21 Oct 2008 07:10:25 +0000 Subject: [PATCH] Fixed some problems with SFTP range support to fix test cases 634 through 637. --- CHANGES | 4 ++++ TODO-RELEASE | 2 -- lib/ssh.c | 18 ++++++++++++++---- tests/data/DISABLED | 4 ---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index af237e1b5a..9a42f0a267 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,10 @@ Changelog +Daniel Fandrich (21 Oct 2008) +- Fixed some problems with SFTP range support to fix test cases 634 through + 637. + Daniel Fandrich (17 Oct 2008) - Fixed a compile error reported by Albert Chin on AIX and IRIX when using GTLS. diff --git a/TODO-RELEASE b/TODO-RELEASE index 36a22ed2d3..282fa99792 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -15,8 +15,6 @@ Awaiting feedback, updates or removal: 182 - Make CURLINFO_LASTSOCKET accessible during perform -187 - Failing SFTP range tests cases 634 through 637 - Patches pending commit: 183 - "libcurl issue with IPv6 and c-ares" diff --git a/lib/ssh.c b/lib/ssh.c index 005eb265fd..19b685f304 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; } diff --git a/tests/data/DISABLED b/tests/data/DISABLED index 012450fb0e..2055e9f167 100644 --- a/tests/data/DISABLED +++ b/tests/data/DISABLED @@ -3,7 +3,3 @@ # test cases are run by runtests.pl. Just add the plain test case numbers, one # per line. # Lines starting with '#' letters are treated as comments. -634 -635 -636 -637