aboutsummaryrefslogtreecommitdiff
path: root/lib/tftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tftp.c')
-rw-r--r--lib/tftp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/tftp.c b/lib/tftp.c
index ed631fad8..18c9472d3 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -286,6 +286,9 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
file name so we skip the always-present first letter of the path string. */
filename = curl_easy_unescape(data, &state->conn->data->reqdata.path[1], 0,
NULL);
+ if (!filename)
+ return CURLE_OUT_OF_MEMORY;
+
snprintf((char *)&state->spacket.data[2],
TFTP_BLOCKSIZE,
"%s%c%s%c", filename, '\0', mode, '\0');
@@ -673,9 +676,9 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done)
}
/* Run the TFTP State Machine */
- for(tftp_state_machine(state, TFTP_EVENT_INIT);
- state->state != TFTP_STATE_FIN;
- tftp_state_machine(state, event) ) {
+ for(code=tftp_state_machine(state, TFTP_EVENT_INIT);
+ (state->state != TFTP_STATE_FIN) && (code == CURLE_OK);
+ code=tftp_state_machine(state, event) ) {
/* Wait until ready to read or timeout occurs */
rc=Curl_socket_ready(state->sockfd, CURL_SOCKET_BAD, state->retry_time * 1000);
@@ -761,6 +764,8 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done)
}
}
+ if(code)
+ return code;
/* Tell curl we're done */
code = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);