bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gawk 3.1.6 bug in /inet/tcp/lport/0/0


From: Corinna Vinschen
Subject: Re: gawk 3.1.6 bug in /inet/tcp/lport/0/0
Date: Mon, 3 Dec 2007 11:38:01 +0100
User-agent: Mutt/1.5.16 (2007-06-09)

Hi Aharon,

On Nov 30 11:16, Aharon Robbins wrote:
> Richard and Corinna:
> > On Nov 15 23:07, Aharon Robbins wrote:
> > > Greetings. Re the below. I don't get any such message under Linux.
> > > Please talk to the cygwin people directly. I have bcc'ed the Cygwin
> > > contact for gawk, so I hope she will be in touch w/you directly.
> > > [...]
> > > > From: Richard Narum 
> > > >[...]
> > > > #!/bin/sh 
> > > >
> > > > gawk ' 
> > > > BEGIN { 
> > > > RS = ORS = "\r\n" 
> > > > HttpService = "/inet/tcp/8080/0/0" 
> > > > Hello = "<HTML><HEAD></HEAD><BODY><PRE>Hello 
> > > > World!</PRE></BODY></HTML>" 
> > > > Len = length(Hello) + length(ORS) 
> > > > while ("awk" != "complex") { 
> > > > print "HTTP/1.0 200 OK" |& HttpService 
> > > > print "Content-Length: " Len ORS |& HttpService 
> > > > print Hello |& HttpService 
> > > > while ((HttpService |& getline) > 0) 
> > > > continue; 
> > > > close(HttpService) 
> > > > } 
> > > > } 
> > > > ' 
> > > >
> > > > I get the following error. 
> > > >
> > > >
> > > > gawk: cmd. line:8: fatal: remote host and port information (0, 0) 
> > > > invalid 
> >
> > That's a regression in io.c, function socketopen.  The 3.1.5 code
> > called gethostbyname on a hostname "0", which leads to gethostbyname
> > returning NULL.  However, this wasn't a problem because the code
> > explicitely checked for an input remote address of "0" and, if so,
> > allowed gethostbyname to fail without socketopen to fail:
> > [...]
> > In 3.1.6, the function getaddrinfo is used.  If getaddrinfo returns -1,
> > gawk fails to open the socket, [...]
> 
> I looked into this.  The use of `any_remote_host' changed from 3.1.5 to 3.1.6.
> In 3.1.6 it is a correctly-used boolean and the logic that's there is fine.
> 
> Under Linux, even when using the replacement getaddrinfo that calls 
> gethostbyname,
> a hostname argument of "0" still seems to "work", in that gethostbyname does 
> NOT
> return NULL.  This is a bit weird.

I'm not quite sure if that's ok.  Giving a "0" to gethostbyname is
beyond the scope of the gethostbyname function.  SUSv3 has only this to
say on the subject(*):

  "The name argument of gethostbyname() shall be a node name; the
   behavior of gethostbyname() when passed a numeric address string is
   unspecified. For IPv4, a numeric address string shall be in the
   dotted-decimal notation described in inet_addr()."

It looks like returning a "0" hostent structure is covered by allowing
unspecified behaviour.  Personally I'd rather think that gethostbyname
should always return NULL with h_errno set to HOST_NOT_FOUND, as Cygwin
(resp. WinSock) does.

> Please try it out and let me know.

It fixes this problem on Cygwin.


Thanks,
Corinna


>       * io.c (socketopen): Use NULL as first argument to `getaddrinfo'
>       if any_remote_host is true. Should help on Non-GLIBC systems.
> 
> 
> ===================================================================
> --- io.c      11 Aug 2007 19:49:23 -0000      1.13
> +++ io.c      30 Nov 2007 09:11:22 -0000
> @@ -1208,7 +1208,7 @@
>               rhints.ai_family = lhints.ai_family;
>               rhints.ai_protocol = lhints.ai_protocol;
>  
> -             rerror = getaddrinfo (remotehostname, remotepname, &rhints, 
> &rres);
> +             rerror = getaddrinfo (any_remote_host ? NULL : remotehostname, 
> remotepname, &rhints, &rres);
>               if (rerror) {
>                       if (lres0 != NULL)
>                               freeaddrinfo(lres0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]