curl-users
[ curl-Bugs-526568 ] Content type is truncated
Date: Wed, 06 Mar 2002 11:17:38 -0800
Bugs item #526568, was opened at 2002-03-06 11:17
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=100976&aid=526568&group_id=976
Category: libcurl
Group: wrong behaviour
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: Content type is truncated
Initial Comment:
curl_easy_getinfo(..., CURLINFO_CONTENT_TYPE, ...)
returns content type that is truncated by one character
at the end.
I suspect that the problem is in transfer.c, line 481:
/* Find the first non-space letter */
for(start=k->p+14;
*start && isspace((int)*start);
start++);
/* count all non-space letters following */
--->>> for(end=start+1, len=0;
*end && !isspace((int)*end);
end++, len++);
/* allocate memory of a cloned copy */
data->info.contenttype = malloc(len + 1);
if (NULL == data->info.contenttype)
return CURLE_OUT_OF_MEMORY;
Since end=start+1 and *start is not examined any more
(for the case of *start == 0), we have already counted
one non-space character. However, len is initialized at
0. Therefore the length of content-type header is
calculated to be one less than the actual value and
less bytes are allocated and copied.
CURL version is 7.9.4.
I would suggest changing line 481 to
for(end=start, len=0;
This would count right number of bytes and also check
for the condition where *start == 0.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=100976&aid=526568&group_id=976
Received on 2002-03-06