zero terminate the buffer spitout() returns, as the sws.c code depends on
that!
This commit is contained in:
Родитель
85dd4bfb8d
Коммит
c073625fb9
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче