You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Greg Stein <gs...@lyra.org> on 1999/04/15 19:40:53 UTC

Re: cvs commit: apache-apr/include apr_network_io.h

rbb@hyperreal.org wrote:
> 
> rbb         99/04/15 08:41:20
> 
>   Modified:    apr/network_io/unix networkio.h sockets.c
>                docs     networkio.txt
>                include  apr_network_io.h
>   Log:
>   Cleaned up some memory leaks in network code. And made the sockets know their
>   own hostname.
>...
>   +    if (gethostname(thesocket->hostname, MAXHOSTNAMELEN + 1) == -1) {
>   +        free(thesocket);
>   +        return NULL;
>   +    }
>   +

I believe that +1 could end up causing a buffer overflow(!). Also, if
the hostname is longer than MAXHOSTNAMELEN, then it could return -1
(rather than simply truncating). Not sure if we need to deal with the
latter case, but it should be noted.

Cheers,
-g

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

Re: cvs commit: apache-apr/include apr_network_io.h

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
You are correct Greg.  I was rushing again.  It doesn't matter though,
because I was trying to solve a problem I didn't need to solve with this,
so I am chinging this code in the next few minutes.

Ryan


On Thu, 15 Apr 1999, Greg Stein wrote:

> rbb@hyperreal.org wrote:
> > 
> > rbb         99/04/15 08:41:20
> > 
> >   Modified:    apr/network_io/unix networkio.h sockets.c
> >                docs     networkio.txt
> >                include  apr_network_io.h
> >   Log:
> >   Cleaned up some memory leaks in network code. And made the sockets know their
> >   own hostname.
> >...
> >   +    if (gethostname(thesocket->hostname, MAXHOSTNAMELEN + 1) == -1) {
> >   +        free(thesocket);
> >   +        return NULL;
> >   +    }
> >   +
> 
> I believe that +1 could end up causing a buffer overflow(!). Also, if
> the hostname is longer than MAXHOSTNAMELEN, then it could return -1
> (rather than simply truncating). Not sure if we need to deal with the
> latter case, but it should be noted.
> 
> Cheers,
> -g
> 
> --
> Greg Stein, http://www.lyra.org/
> 

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.