cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURL_DOES_CONVERSIONS overwriting const data

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 28 Aug 2008 09:40:48 +0200 (CEST)

On Wed, 27 Aug 2008, Dan Fandrich wrote:

> There are a number of places in the code where Curl_client_write() is called
> with a string literal as an argument, e.g.
>
> Curl_client_write(conn, CLIENTWRITE_BOTH, (char *)"Accept-ranges: bytes\r\n", 0)
>
> Note the suspicious (char *) cast in there.

Oh yes, that's not a pretty sight.

We should probably make Curl_client_write() take a const char *, remove all
those typecasts and for the case where CURL_DOES_CONVERSIONS or
CURL_DO_LINEEND_CONV is defined we make special functions for them that
converts into a temp buffer and sends away from that.

Or is there a better way?

The current way of having functions that simply alters the existing buffer is
rather ugly imho.

(I don't consider this a crucial bug fix for the pending release since this is
not new code in any way.)

-- 
  / daniel.haxx.se
Received on 2008-08-28