gethostbyname() problem?

Christopher Faylor cgf-no-personal-reply-please@cygwin.com
Sun Feb 6 23:44:00 GMT 2005


On Sun, Feb 06, 2005 at 03:01:29PM -0800, Yitzchak Scott-Thoennes wrote:
>On Sun, Feb 06, 2005 at 12:05:30PM +0100, Corinna Vinschen wrote:
>> On Feb  6 00:35, Brian Dessent wrote:
>> > -  static int a, b, c, d;
>> > +  static int a, b, c, d, n;
>> >  
>> >    sig_dispatch_pending ();
>> >    if (check_null_str_errno (name))
>> >      return NULL;
>> >  
>> > -  if (sscanf (name, "%d.%d.%d.%d", &a, &b, &c, &d) == 4)
>> > +  if (sscanf (name, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4 && (unsigned)n == strlen (name))
>>
>> Thanks for the patch, Brian.  Do you also have a nice ChangeLog entry
>> for me?
>
>I've always done this like below; then the n==strlen(name) check isn't
>needed (since the ==4 verifies that %c wasn't used).  Even using the
>%n, there's no reason to make n static, is there?

There has been no reason to make a, b, c, d static either AFAICT.
This whole function is frightfully non-reentrant, but I knew that.

cgf



More information about the Cygwin-patches mailing list