From: Daniel Stenberg Date: Mon, 29 Nov 2004 18:26:09 +0000 (+0000) Subject: zero terminate the buffer spitout() returns, as the sws.c code depends on X-Git-Tag: curl-7_12_3~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c073625fb905b41703589f2af5e4039db19746f7;p=curl zero terminate the buffer spitout() returns, as the sws.c code depends on that! --- diff --git a/tests/server/getpart.c b/tests/server/getpart.c index 0ae6c391c..a544c517b 100644 --- a/tests/server/getpart.c +++ b/tests/server/getpart.c @@ -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; }