delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/08/12/06:30:27

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Fri, 12 Aug 2011 12:29:27 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: buffer size calculation in gethostby_helper()
Message-ID: <20110812102927.GB7469@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <201108120130 DOT p7C1UN3b012281 AT matsrv DOT math DOT cas DOT cz>
MIME-Version: 1.0
In-Reply-To: <201108120130.p7C1UN3b012281@matsrv.math.cas.cz>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019