[Top][All Lists]
[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: |
Aharon Robbins |
Subject: |
Re: gawk 3.1.6 bug in /inet/tcp/lport/0/0 |
Date: |
Sun, 18 Nov 2007 06:28:49 +0200 |
Thanks for the analysis. I suppose this makes this My Problem, so I
will look into fixing it. :-)
Thanks,
Arnold
> Date: Thu, 15 Nov 2007 22:45:01 +0100
> From: Corinna Vinschen <address@hidden>
> Subject: Re: gawk 3.1.6 bug in /inet/tcp/lport/0/0
> To: Aharon Robbins <address@hidden>
> Cc: address@hidden, address@hidden
>
> 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.
> >
> > Thanks,
> >
> > Arnold
> >
> > > From: Richard Narum
> > > FYI,
> > >
> > > I believe I have encountered a bug in gawk 3.1.6 with the special file
> > > name /inet/tcp using lport != 0 and rhost = rport = 0. I am running
> > > Cygwin on Windows XP version "CYGWIN_NT-5.1 1.5.24(0.156/4/2) 2007-01-31
> > > 10:57". I had version "GNU Awk 3.1.6", Cygwin install calls it 3.1.6-1,
> > > and had to roll back to "GNU Awk 3.1.5", Cygwin's 3.1.5-4 . Version
> > > 3.1.6 fails and 3.1.5 seems to work fine.
> > >
> > > I am running the following script.
> > >
> > >
> > > #!/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:
>
> io.c:
>
> 1137 struct hostent *hp = gethostbyname(remotehostname);
> [...]
> 1140 int any_remote_host = strcmp(remotehostname, "0");
> [...]
> 1180 if (socket_fd < 0 || socket_fd == INVALID_HANDLE
> * 1181 || (hp == NULL && any_remote_host != 0))
> 1182 return INVALID_HANDLE;
>
> In 3.1.6, the function getaddrinfo is used. If getaddrinfo returns -1,
> gawk fails to open the socket, because there's no further test for
> any_remote_host. I don't know why this works on Linux, but it certainly
> fails on Cygwin, because Cygwin doesn't have (so far) a getaddrinfo
> function and so the fallback function in missing_d is used, which in turn
> uses gethostbyname. Since gethostbyname fails with the remote hostname
> "0", the whole socketopen function fails now. I'm sure this isn't a
> problem only on Cygwin, though, but on any platform not having its own
> getaddrinfo function.
>
> Since the socketopen function has changed so enormously, I don't see an
> easy patch for this.
>
> Corinna