buffer size calculation in gethostby_helper()

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Aug 12 10:30:00 GMT 2011


On Aug 12 03:10, Jan Kolar wrote:
> 
> Dear Corinna,
> Please note that in net.cc, some kind of
>               string_size += addrsize_out;
> is missing somewhere, which affects a buffer allocation.
> See the two locations in diff.
> [...]
> DIFF
> $ cd /usr/src/cygwin-1.7.6-1/winsup/ && diff -up
> ../rozbalene-orig-src.tar.bz2/cygwin-1.7.6-1/winsup/cygwin/net.cc
> cygwin/net.cc
> ---
> ../rozbalene-orig-src.tar.bz2/cygwin-1.7.6-1/winsup/cygwin/net.cc
> 2010-08-16 15:55:07.000000000 +0200
> +++ cygwin/net.cc    2011-08-12 00:07:51.709992400 +0200
> @@ -1109,6 +1109,8 @@ gethostby_helper (const char *name, cons
>        else if (address_len != namelen1)
>          continue;
>        address_count++;
> +          string_size += addrsize_out; // jk-2011 hope this fixes
> the BUG below
> +          system_printf ("Note: JK hopping to fix the -4 bug in
> net.cc saying (if defed DEBUGGING) 'Please debug.' ");
>      }
>        /* Update the records */
>        curptr->type = antype; /* Host byte order */
> @@ -1192,7 +1194,7 @@ gethostby_helper (const char *name, cons
>            else
>          memcpy (string_ptr, curptr->data, addrsize_in);
>            string_ptr += addrsize_out;
> -          string_size -= addrsize_out;
> +          string_size -= addrsize_out; // jk-2011 FIXME BUG:   this
> makes it -4 sometimes - before my fix.
>            continue;
>          }
>  #ifdef DEBUGGING

This looks basically correct to me, but the original code is not
from me.  Pierre, would you mind to have a look?


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list