1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

zero terminate the buffer spitout() returns, as the sws.c code depends on

that!
This commit is contained in:
Daniel Stenberg 2004-11-29 18:26:09 +00:00
parent 85dd4bfb8d
commit c073625fb9

View File

@ -58,14 +58,14 @@ char *appendstring(char *string, /* original string */
char base64) /* 1 if base64 encoded */
{
size_t len = strlen(buffer);
size_t needed_len = len + *stringlen;
size_t needed_len = len + *stringlen + 1;
char buf64[256]; /* big enough? */
if(base64) {
/* decode the given buffer first */
len = Curl_base64_decode(buffer, buf64); /* updated len */
buffer = buf64;
needed_len = len + *stringlen; /* recalculate */
needed_len = len + *stringlen + 1; /* recalculate */
}
if(needed_len >= *stralloc) {
@ -83,6 +83,7 @@ char *appendstring(char *string, /* original string */
/* memcpy to support binary blobs */
memcpy(&string[*stringlen], buffer, len);
*stringlen += len;
string[*stringlen]=0;
return string;
}
@ -217,8 +218,10 @@ int main(int argc, char **argv)
}
else {
size_t size;
unsigned int i;
const char *buffer = spitout(stdin, argv[1], argv[2], &size);
printf("%s", buffer);
for(i=0; i< size; i++)
printf("%c", buffer[i]);
}
return 0;
}