cURL / Mailing Lists / curl-library / Single Mail

curl-library

Possible bug found for call to create_hostcache_id() method

From: Sharma, Amit <as230007_at_exchange.Canada.NCR.com>
Date: Tue, 14 Oct 2003 15:15:45 -0400

Hi List/Daniel,

Looks like there is a possible bug in cache_resolve_response() method.

In the resolve target host function, Curl_resolv(conn,
conn->name,conn->port,&hostaddr), therez a call made to create_hostcache_id
(hostname,port,&entry_len)
routine to create the dns cache entry for the URL for caching purpose. The
third argument (&entry_len) passed to this method is an integer reference.
However, the signature for this function specifies this argument to be of
type ssize_t *entry_len.

static char * create_hostcache_id(char *server, int port, ssize_t
*entry_len);

As such, when libcurl is built for 64-bit (like mine), this third argument
does not get passed to the function properly and the subsequent call to
malloc fails. Error from this routine is interpreted as: unable to resolve
name. Error code (6).

A quick dump of my debugger shows that the call to the function
create_hostcache_id() has its third argument, entry_len, set to 12 (I was
passing a 12 character URL) and its address as &entry_len =
0xffffffff7fffe92c.

Inside the definition, the dump shows the following:
&entry_len = 0xffffffff7fffe838
entry_len = 0xffffffff7fffe92c

And the code fails at

 /* Allocate the new entry id */
  id = malloc(*entry_len + 1);
  if (!id)
    return NULL;

This is because *entry_len is now a 64-bit variable and it does not point
the integer anymore.
Dump shows a value of *entry_len = 5153960755.

 
Looking forward to comments/suggestions

Gracias,
Amit

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
Received on 2003-10-14