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 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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