1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

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.
This commit is contained in:
Ben Greear 2010-03-21 23:24:36 +01:00 committed by Daniel Stenberg
parent 930742776a
commit ad76d58e7f

View File

@ -398,12 +398,17 @@ static CURLcode tftp_parse_option_ack(tftp_state_data_t *state,
long tsize = 0; long tsize = 0;
tsize = strtol( value, NULL, 10 ); tsize = strtol( value, NULL, 10 );
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) { if(!tsize) {
failf(data, "invalid tsize -:%s:- value in OACK packet", value); failf(data, "invalid tsize -:%s:- value in OACK packet", value);
return CURLE_TFTP_ILLEGAL; return CURLE_TFTP_ILLEGAL;
} }
Curl_pgrsSetDownloadSize(data, tsize); Curl_pgrsSetDownloadSize(data, tsize);
infof(data, "%s (%ld)\n", "tsize parsed from OACK", tsize); }
} }
} }
@ -1471,7 +1476,10 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
code = tftp_perform(conn, done); code = tftp_perform(conn, done);
/* If we have encountered an 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); code = tftp_translate_code(state->error);
return code; return code;