X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,TW_CP X-Spam-Check-By: sourceware.org Resent-Message-Id: <201108120130 DOT p7C1UN3b012281 AT matsrv DOT math DOT cas DOT cz> Message-Id: <201108120130.p7C1UN3b012281@matsrv.math.cas.cz> Date: Fri, 12 Aug 2011 03:10:13 +0200 From: Jan Kolar MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: buffer size calculation in gethostby_helper() Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Resent-From: kolar AT math DOT cas DOT cz Resent-Date: Fri, 12 Aug 2011 03:30:23 +0200 Resent-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 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. (I do not see well how the two loops (passes) communicate, which might well be the origin of the problem.) The problem was discovered with mplayer with some URLs, with DEBUGGING defined. Best regards Jan -------------------------- EXAMPLE $ mplayer.exe 'http://www.ceskatelevize.cz/ivysilani/1096898594-udalosti-komentare/211411000370805/' MPlayer SVN-r32518-snapshot-4.5.1 (C) 2000-2010 MPlayer Team 159 audio & 349 video codecs Playing http://www.ceskatelevize.cz/ivysilani/1096898594-udalosti-komentare/211411000370805/. Resolving www.ceskatelevize.cz for AF_INET6... Couldn't resolve name for AF_INET6: www.ceskatelevize.cz Resolving www.ceskatelevize.cz for AF_INET... 223037 [main] mplayer 7812 gethostby_helper: Note: JK hopping to fix the -4 bug in net.cc saying (if defed DEBUGGING) 'Please debug.' Connecting to server www.ceskatelevize.cz[212.47.26.209]: 80... Cache size set to 320 KBytes Cache fill: 0.00% (0 bytes) Exiting... (End of file) ------------------------ 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 -- 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