delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/11/01/23:28:24

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <3.0.5.32.20031101231606.00831260@incoming.verizon.net>
X-Sender: vze1u1tg AT incoming DOT verizon DOT net
Date: Sat, 01 Nov 2003 23:16:06 -0500
To: cygwin AT cygwin DOT com
From: "Pierre A. Humblet" <Pierre DOT Humblet AT ieee DOT org>
Subject: Re: Segmentation Fault of ssh3.7.1 with cygwin1.5.5-1 in W95
In-Reply-To: <20031101122752.GA16693@cygbert.vinschen.de>
References: <3 DOT 0 DOT 5 DOT 32 DOT 20031031190541 DOT 00826670 AT incoming DOT verizon DOT net>
<3 DOT 0 DOT 5 DOT 32 DOT 20031030202558 DOT 00828400 AT incoming DOT verizon DOT net>
<3 DOT 0 DOT 5 DOT 32 DOT 20031029214604 DOT 0082b8c0 AT incoming DOT verizon DOT net>
<200310291905 DOT h9TJ5eG5028353 AT pion DOT ivic DOT ve>
<3 DOT 0 DOT 5 DOT 32 DOT 20031029214604 DOT 0082b8c0 AT incoming DOT verizon DOT net>
<3 DOT 0 DOT 5 DOT 32 DOT 20031030202558 DOT 00828400 AT incoming DOT verizon DOT net>
<3 DOT 0 DOT 5 DOT 32 DOT 20031031190541 DOT 00826670 AT incoming DOT verizon DOT net>
Mime-Version: 1.0

--=====================_1067764566==_
Content-Type: text/plain; charset="us-ascii"

At 01:27 PM 11/1/2003 +0100, you wrote:
>On Fri, Oct 31, 2003 at 07:05:41PM -0500, Pierre A. Humblet wrote:
>> At 11:52 AM 10/31/2003 +0100, Corinna Vinschen wrote:
>> >I've just again tested it on 98 and it works fine.  Could you please
>> >figure out what happens on your machine?
>> 
>> 2 things:
>> - I had accidentally deleted the next (23) line in services, so awk 
>>   didn't find the pattern.
>
>Ok, so how do you suggest to react in the script if that happens?
>Should the script just emit a warning or should it append the ssh lines
>at the end of the services file?  The new script will just emit a
>warning for now.

Both solutions are fine with me. 
 
>> - ssh crashes even with the CR. I also had to shorten the line. It works
>>   with 18 spaces between {tcp,udp} and the #
>
>Ouch.  How many spaces do I emit currently... hmm, 27.  This matches
>the file layout on NT.  A quick look on a 98 machine... yes, only
>18 spaces.  Oh boy...
>
>> Please send the next version, just to be sure.
>
>I've created a new script and attached it to this mail.

I have just spent a few hours on this :(

What I wrote initially is correct: ssh doesn't crash when the ssh
lines are removed from the services file.

But neither having a CR nor shortening the line have much 
to do with the problem. 
The only reason they made a difference is that I had the services
file opened in Word. In that case the getservbyname call fails
cleanly and ssh uses the default.

The real problem is that the s_proto pointer of the struct servent
returned by the Windows getservbyname on Win95 is invalid. 
That didn't matter before dup_ent was introduced.
The problem concerns all services, not only ssh, and also
affects getservbyport.

Olivier AT erg ~
$ gcc getserv.c -mno-cygwin -lwsock32

Olivier AT erg ~
$ ./a 25
ptr = 410732
name 4107cc smtp
aliases:
0, 4107e9 mail
port 25
Checking validy of ptr->s_proto 7e90041

(IsBadStringPtr returns true)

On Win98 one gets
~: ./a 25
ptr = 861400
name 86141d smtp
aliases:
0, 861418 mail
port 25
Checking validy of ptr->s_proto 861422
proto tcp

I attach the getserv.c program, in case others want to experiment.
A solution would be to use IsBadStringPtr (or wincap) in dup_ent.
A workaround is to delete lines in the services file.

Pierre


--=====================_1067764566==_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="getserv.c"

/*  gcc getserv.c -lwsock32 -mno-cygwin */
#define __USE_W32_SOCKETS

#include <windows.h>
#include <stdio.h>
#if defined(__CYGWIN__) && !defined(__USE_W32_SOCKETS)
#include <netdb.h>
#endif

main(int argc, char * argv[] )
{
  struct servent * ptr;
  int i;

#ifdef __USE_W32_SOCKETS
  WORD wVersionRequested;
  WSADATA wsaData;
  int err;
  
  wVersionRequested =3D MAKEWORD( 2, 2 );
 
  err =3D WSAStartup( wVersionRequested, &wsaData );
  if ( err !=3D 0 ) {
    printf("Cannot initialize\n");
    return;
  }
#endif

  if (argc < 2) {
    printf("Need argument\n");
    exit(1);
  }
  if (!isdigit(*argv[1]))
    ptr =3D getservbyname (argv[1], "tcp");
  else
    ptr =3D getservbyport (ntohs (atoi (argv[1])), "tcp");
  printf("ptr =3D %x\n", ptr);

  if (ptr)
  {
    printf("name %x %s\n", ptr->s_name, ptr->s_name? ptr->s_name : "NULL");
    printf("aliases:\n");
    for (i =3D 0; ptr->s_aliases[i]; i++)
      printf("%d, %x %s\n", i, ptr->s_aliases[i], ptr->s_aliases[i]);
    printf("port %d\n", (int) ntohs(ptr->s_port));
    printf("Checking validy of ptr->s_proto %x\n", ptr->s_proto);   
    if (!IsBadStringPtr (ptr->s_proto, 10))
      printf("proto %s\n", ptr->s_proto);
    
   }
  exit (0);
}



--=====================_1067764566==_
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--=====================_1067764566==_--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019