diff options
author | Ben Greear <greearb@candelatech.com> | 2010-03-21 23:24:36 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2010-03-21 23:24:36 +0100 |
commit | ad76d58e7f1f26739255c22a69725c83eb47511a (patch) | |
tree | 5d876e62c7dd095d8ca81134095367b591b0c527 /lib/tftp.c | |
parent | 930742776ad643b57577c29606e0af827b714d9f (diff) |
Fix tftp return codes and tsize upload handling
Error codes were not properly returned to the main curl code (and on to apps
using libcurl).
tftp was crapping out when tsize == 0 on upload, but I see no reason to fail
to upload just because the remote file is zero-length. Ignore tsize option on
upload.
Diffstat (limited to 'lib/tftp.c')
-rw-r--r-- | lib/tftp.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/tftp.c b/lib/tftp.c index cab6c09d4..dde17735a 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -398,12 +398,17 @@ static CURLcode tftp_parse_option_ack(tftp_state_data_t *state, long tsize = 0; tsize = strtol( value, NULL, 10 ); - if(!tsize) { - failf(data, "invalid tsize -:%s:- value in OACK packet", value); - return CURLE_TFTP_ILLEGAL; - } - Curl_pgrsSetDownloadSize(data, tsize); infof(data, "%s (%ld)\n", "tsize parsed from OACK", tsize); + + /* tsize should be ignored on upload: Who cares about the size of the + remote file? */ + if (!data->set.upload) { + if(!tsize) { + failf(data, "invalid tsize -:%s:- value in OACK packet", value); + return CURLE_TFTP_ILLEGAL; + } + Curl_pgrsSetDownloadSize(data, tsize); + } } } @@ -1471,8 +1476,11 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done) code = tftp_perform(conn, done); - /* If we have encountered an error */ - code = tftp_translate_code(state->error); + /* If tftp_perform() returned an error, use that for return code. If it + was OK, see if tftp_translate_code() has an error. */ + if (code == CURLE_OK) + /* If we have encountered an internal tftp error, translate it. */ + code = tftp_translate_code(state->error); return code; } |