Fixed a small memory leak in tftp uploads discovered by curl's memory leak

detector.  Also changed tftp downloads to URL-unescape the downloaded
file name.
This commit is contained in:
Dan Fandrich 2007-01-16 18:33:25 +00:00
parent f11d3c329c
commit bbdc483671
2 changed files with 10 additions and 5 deletions

View File

@ -6,6 +6,11 @@
Changelog
Dan F (16 January 2007)
- Fixed a small memory leak in tftp uploads discovered by curl's memory leak
detector. Also changed tftp downloads to URL-unescape the downloaded
file name.
Daniel (14 January 2007)
- David McCreedy provided libcurl changes for doing HTTP communication on
non-ASCII platforms. It does add some complexity, most notably with more

View File

@ -255,10 +255,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
{
int sbytes;
const char *mode = "octet";
/* As RFC3617 describes the separator slash is not actually part of the file
name so we skip the always-present first letter of the path string. */
char *filename = &state->conn->data->reqdata.path[1];
char *filename;
struct SessionHandle *data = state->conn->data;
CURLcode res = CURLE_OK;
@ -281,7 +278,6 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
if(data->set.upload) {
/* If we are uploading, send an WRQ */
setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
filename = curl_easy_unescape(data, filename, 0, NULL);
state->conn->data->reqdata.upload_fromhere = (char *)&state->spacket.data[4];
if(data->set.infilesize != -1)
Curl_pgrsSetUploadSize(data, data->set.infilesize);
@ -290,6 +286,9 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
/* If we are downloading, send an RRQ */
setpacketevent(&state->spacket, TFTP_EVENT_RRQ);
}
/* As RFC3617 describes the separator slash is not actually part of the
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);
snprintf((char *)&state->spacket.data[2],
TFTP_BLOCKSIZE,
"%s%c%s%c", filename, '\0', mode, '\0');
@ -301,6 +300,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
if(sbytes < 0) {
failf(data, "%s\n", Curl_strerror(state->conn, Curl_sockerrno()));
}
Curl_safefree(filename);
break;
case TFTP_EVENT_ACK: /* Connected for transmit */