diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-05-23 09:47:57 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-05-23 09:47:57 +0000 |
commit | b2ef79ef3d47b3768e16103b44c9a129196ed280 (patch) | |
tree | 80673679318f7574868cef91aa21d363a1fd86a8 /lib | |
parent | f488874ff5b804c2b088ddda71ec275be3dce52d (diff) |
Rudy Koento's problem fixed, test case 66 verifies this.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/transfer.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index 9bc9f1020..c321da1ee 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -285,6 +285,8 @@ CURLcode Curl_readwrite(struct connectdata *conn, /* header line within buffer loop */ do { int hbufp_index; + int rest_length; + int full_length; /* str_start is start of line within buf */ k->str_start = k->str; @@ -326,22 +328,24 @@ CURLcode Curl_readwrite(struct connectdata *conn, break; /* read more and try again */ } - /* decrease the size of the remaining buffer */ - nread -= (k->end_ptr - k->str)+1; + /* decrease the size of the remaining (supposed) header line */ + rest_length = (k->end_ptr - k->str)+1; + nread -= rest_length; k->str = k->end_ptr + 1; /* move past new line */ + full_length = k->str - k->str_start; + /* * We're about to copy a chunk of data to the end of the * already received header. We make sure that the full string * fit in the allocated header buffer, or else we enlarge * it. */ - if (k->hbuflen + (k->str - k->str_start) >= + if (k->hbuflen + full_length >= data->state.headersize) { char *newbuff; - long newsize=MAX((k->hbuflen+ - (k->str-k->str_start))*3/2, + long newsize=MAX((k->hbuflen+full_length)*3/2, data->state.headersize*2); hbufp_index = k->hbufp - data->state.headerbuff; newbuff = (char *)realloc(data->state.headerbuff, newsize); @@ -355,9 +359,9 @@ CURLcode Curl_readwrite(struct connectdata *conn, } /* copy to end of line */ - strncpy (k->hbufp, k->str_start, k->str - k->str_start); - k->hbufp += k->str - k->str_start; - k->hbuflen += k->str - k->str_start; + strncpy (k->hbufp, k->str_start, full_length); + k->hbufp += full_length; + k->hbuflen += full_length; *k->hbufp = 0; k->p = data->state.headerbuff; @@ -372,7 +376,14 @@ CURLcode Curl_readwrite(struct connectdata *conn, !checkhttpprefix(data, data->state.headerbuff)) { /* this is not the beginning of a HTTP first header line */ k->header = FALSE; - k->badheader = HEADER_PARTHEADER; + if(nread) + /* since there's more, this is a partial bad header */ + k->badheader = HEADER_PARTHEADER; + else { + /* this was all we read so its all a bad header */ + k->badheader = HEADER_ALLBAD; + nread = rest_length; + } break; } } |