mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
tool_cb_dbg.c: fix tool_cb_dbg() to behave properly even for size 0
curl segfault in debug callback triggered with CURLINFO_HEADER_OUT and size 0 bug: http://curl.haxx.se/bug/view.cgi?id=3511794
This commit is contained in:
parent
459435dca1
commit
4bdb664c33
@ -108,19 +108,21 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
|
|||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case CURLINFO_HEADER_OUT:
|
case CURLINFO_HEADER_OUT:
|
||||||
for(i = 0; i < size - 1; i++) {
|
if(size > 0) {
|
||||||
if(data[i] == '\n') { /* LF */
|
for(i = 0; i < size - 1; i++) {
|
||||||
if(!newl) {
|
if(data[i] == '\n') { /* LF */
|
||||||
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
|
if(!newl) {
|
||||||
|
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
|
||||||
|
}
|
||||||
|
(void)fwrite(data + st, i - st + 1, 1, output);
|
||||||
|
st = i + 1;
|
||||||
|
newl = FALSE;
|
||||||
}
|
}
|
||||||
(void)fwrite(data + st, i - st + 1, 1, output);
|
|
||||||
st = i + 1;
|
|
||||||
newl = FALSE;
|
|
||||||
}
|
}
|
||||||
|
if(!newl)
|
||||||
|
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
|
||||||
|
(void)fwrite(data + st, i - st + 1, 1, output);
|
||||||
}
|
}
|
||||||
if(!newl)
|
|
||||||
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
|
|
||||||
(void)fwrite(data + st, i - st + 1, 1, output);
|
|
||||||
newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE;
|
newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE;
|
||||||
traced_data = FALSE;
|
traced_data = FALSE;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user