buffer size calculation in gethostby_helper()

Jan Kolar kolar@math.cas.cz
Fri Aug 12 01:30:00 GMT 2011


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



More information about the Cygwin mailing list