mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
sendf: remove use of BUFSIZE from debug data conversions
The buffer can have other sizes.
This commit is contained in:
parent
e40e9d7f0d
commit
7ee52c25f3
25
lib/sendf.c
25
lib/sendf.c
@ -751,21 +751,19 @@ static int showit(struct Curl_easy *data, curl_infotype type,
|
|||||||
{
|
{
|
||||||
static const char s_infotype[CURLINFO_END][3] = {
|
static const char s_infotype[CURLINFO_END][3] = {
|
||||||
"* ", "< ", "> ", "{ ", "} ", "{ ", "} " };
|
"* ", "< ", "> ", "{ ", "} ", "{ ", "} " };
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
char buf[BUFSIZE+1];
|
char *buf = NULL;
|
||||||
size_t conv_size = 0;
|
size_t conv_size = 0;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case CURLINFO_HEADER_OUT:
|
case CURLINFO_HEADER_OUT:
|
||||||
/* assume output headers are ASCII */
|
buf = Curl_memdup(ptr, size);
|
||||||
/* copy the data into my buffer so the original is unchanged */
|
if(!buf)
|
||||||
if(size > BUFSIZE) {
|
return 1;
|
||||||
size = BUFSIZE; /* truncate if necessary */
|
|
||||||
buf[BUFSIZE] = '\0';
|
|
||||||
}
|
|
||||||
conv_size = size;
|
conv_size = size;
|
||||||
memcpy(buf, ptr, size);
|
|
||||||
/* Special processing is needed for this block if it
|
/* Special processing is needed for this block if it
|
||||||
* contains both headers and data (separated by CRLFCRLF).
|
* contains both headers and data (separated by CRLFCRLF).
|
||||||
* We want to convert just the headers, leaving the data as-is.
|
* We want to convert just the headers, leaving the data as-is.
|
||||||
@ -793,9 +791,8 @@ static int showit(struct Curl_easy *data, curl_infotype type,
|
|||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
|
|
||||||
if(data->set.fdebug)
|
if(data->set.fdebug)
|
||||||
return (*data->set.fdebug)(data, type, ptr, size,
|
rc = (*data->set.fdebug)(data, type, ptr, size, data->set.debugdata);
|
||||||
data->set.debugdata);
|
else {
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case CURLINFO_TEXT:
|
case CURLINFO_TEXT:
|
||||||
case CURLINFO_HEADER_OUT:
|
case CURLINFO_HEADER_OUT:
|
||||||
@ -812,7 +809,11 @@ static int showit(struct Curl_easy *data, curl_infotype type,
|
|||||||
default: /* nada */
|
default: /* nada */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
|
free(buf);
|
||||||
|
#endif
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
||||||
|
Loading…
Reference in New Issue
Block a user