aboutsummaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-06-24 11:54:11 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-06-24 11:54:11 +0000
commitfeb2dd283533f842c9b6e4cc2fcc7fd35638d5a0 (patch)
treef0ecc2bd74917e67e3e9853e04a6ca16c2770eb3 /lib/ftp.c
parent5e34f3dc0133333fb398dd4b285a63f58aa441da (diff)
Replaced all uses of sprintf() with the safer snprintf(). It is just a
precaution to prevent mistakes to lead to buffer overflows.
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index fc987faf0..ad9fb6054 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -932,8 +932,9 @@ CURLcode ftp_getfiletime(struct connectdata *conn, char *file)
&year, &month, &day, &hour, &minute, &second)) {
/* we have a time, reformat it */
time_t secs=time(NULL);
- sprintf(buf, "%04d%02d%02d %02d:%02d:%02d GMT",
- year, month, day, hour, minute, second);
+ snprintf(buf, sizeof(conn->data->state.buffer),
+ "%04d%02d%02d %02d:%02d:%02d GMT",
+ year, month, day, hour, minute, second);
/* now, convert this into a time() value: */
conn->data->info.filetime = curl_getdate(buf, &secs);
}
@@ -1506,7 +1507,8 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
return CURLE_FTP_WEIRD_227_FORMAT;
}
- sprintf(newhost, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
+ snprintf(newhost, sizeof(newhost),
+ "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
newhostp = newhost;
newport = (port[0]<<8) + port[1];
}
@@ -2161,7 +2163,8 @@ CURLcode ftp_perform(struct connectdata *conn,
result = ftp_getsize(conn, ftp->file, &filesize);
if(CURLE_OK == result) {
- sprintf(buf, "Content-Length: %" FORMAT_OFF_T "\r\n", filesize);
+ snprintf(buf, sizeof(data->state.buffer),
+ "Content-Length: %" FORMAT_OFF_T "\r\n", filesize);
result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
if(result)
return result;