On Fri, Nov 19, 2010 at 02:57:28PM +0100, Clément Bœsch wrote:
+ noauth_len = strlen(Curl->protocol) + strlen(Curl->hostname) + + strlen(Curl->file) + sizeof("://:65535");
Eeek. Is there even a check that limits the port number to 65535? Either way I think this needs to be done in some simpler way. Maybe using the snprintf return value + 1 when calling it with size == 0. A bit of a waste of CPU time but shouldn't be that bad.
+ if (Curl->port) + snprintf(Curl->noauth_url, noauth_len, "%s://%s:%d%s", + Curl->protocol, Curl->hostname, Curl->port, Curl->file); + else + snprintf(Curl->noauth_url, noauth_len, "%s://%s%s", + Curl->protocol, Curl->hostname, Curl->file);
To avoid code duplication I'd put that maybe in a helper funtion that takes the noauth_len as argument.