public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* buffer size calculation in gethostby_helper()
@ 2011-08-12  1:30 Jan Kolar
  2011-08-12 10:30 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kolar @ 2011-08-12  1:30 UTC (permalink / raw)
  To: cygwin


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: buffer size calculation in gethostby_helper()
  2011-08-12  1:30 buffer size calculation in gethostby_helper() Jan Kolar
@ 2011-08-12 10:30 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2011-08-12 10:30 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-12 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-12  1:30 buffer size calculation in gethostby_helper() Jan Kolar
2011-08-12 10:30 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).