Segmentation Fault of ssh3.7.1 with cygwin1.5.5-1 in W95

Pierre A. Humblet Pierre.Humblet@ieee.org
Sun Nov 2 04:28:00 GMT 2003


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@erg ~
$ gcc getserv.c -mno-cygwin -lwsock32

Olivier@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

-------------- next part --------------
/*  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 = MAKEWORD( 2, 2 );

  err = WSAStartup( wVersionRequested, &wsaData );
  if ( err != 0 ) {
    printf("Cannot initialize\n");
    return;
  }
#endif

  if (argc < 2) {
    printf("Need argument\n");
    exit(1);
  }
  if (!isdigit(*argv[1]))
    ptr = getservbyname (argv[1], "tcp");
  else
    ptr = getservbyport (ntohs (atoi (argv[1])), "tcp");
  printf("ptr = %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 = 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);
}


-------------- next part --------------
--
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/


More information about the Cygwin mailing list