httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <gst...@lyra.org>
Subject Re: cvs commit: apache-2.0/src/lib/apr/network_io/unix sockets.c
Date Mon, 13 Sep 1999 10:02:04 GMT
On Sun, 12 Sep 1999, Ben Laurie wrote:
> Greg Stein wrote:
> > ben@hyperreal.org wrote:
> > > ben         99/09/12 04:19:30
> > >
> > >   Modified:    src/lib/apr/network_io/unix sockets.c
> > >   Log:
> > >   Make ap_getipaddr return the buffer, rather than copy it.
> > >...
> > >    ap_status_t ap_getipaddr(struct socket_t *sock, char **addr)
> > >    {
> > >        char *temp = inet_ntoa(sock->addr->sin_addr);
> > >   -    strcpy(*addr, temp);
> > >   +    *addr=temp;
> > >        return APR_SUCCESS;
> > >    }
> > 
> > inet_ntoa() returns a pointer to a statically allocated buffer.
> > Shouldn't we make a copy of it?
> 
> Possibly, but you'll note the absence of a pool. Err, sorry, context.

Before you changed it, the client passed in the memory to copy it to. Who
said the function itself had to allocate it? IMO, I'm not sure you truly
fixed things :-)

Of course, there is the problem on the client side: how much memory to
allocate? Sometimes, this is solved by passing in the buffer size. The
function can fail if you don't pass enough.

Cheers,
-g

--
Greg Stein, http://www.lyra.org/



Mime
View raw message