aboutsummaryrefslogtreecommitdiff
path: root/lib/base64.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/base64.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/base64.c')
-rw-r--r--lib/base64.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/base64.c b/lib/base64.c
index 987835b4f..2416bca06 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -160,22 +160,22 @@ size_t Curl_base64_encode(const char *inp, size_t insize, char **outptr)
switch(inputparts) {
case 1: /* only one byte read */
- sprintf(output, "%c%c==",
- table64[obuf[0]],
- table64[obuf[1]]);
+ snprintf(output, 5, "%c%c==",
+ table64[obuf[0]],
+ table64[obuf[1]]);
break;
case 2: /* two bytes read */
- sprintf(output, "%c%c%c=",
- table64[obuf[0]],
- table64[obuf[1]],
- table64[obuf[2]]);
+ snprintf(output, 5, "%c%c%c=",
+ table64[obuf[0]],
+ table64[obuf[1]],
+ table64[obuf[2]]);
break;
default:
- sprintf(output, "%c%c%c%c",
- table64[obuf[0]],
- table64[obuf[1]],
- table64[obuf[2]],
- table64[obuf[3]] );
+ snprintf(output, 5, "%c%c%c%c",
+ table64[obuf[0]],
+ table64[obuf[1]],
+ table64[obuf[2]],
+ table64[obuf[3]] );
break;
}
output += 4;