aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2007-01-16 18:33:25 +0000
committerDan Fandrich <dan@coneharvesters.com>2007-01-16 18:33:25 +0000
commitbbdc483671a248b553c1e5ccb42c90a665cea629 (patch)
tree6d052b1c0f2d8aed2d801409af62d6adbca216c3
parentf11d3c329c335a3fb8f01cc4509e2ab7a2abec04 (diff)
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.
-rw-r--r--CHANGES5
-rw-r--r--lib/tftp.c10
2 files changed, 10 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index eb6c127b0..c58379095 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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
diff --git a/lib/tftp.c b/lib/tftp.c
index 76b248fdb..6f1dfaa36 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -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 */