Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Mon, 3 Nov 2003 20:06:32 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Segmentation Fault of ssh3.7.1 with cygwin1.5.5-1 in W95 Message-ID: <20031103190632.GL18706@cygbert.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com 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> <3 DOT 0 DOT 5 DOT 32 DOT 20031102094314 DOT 00839710 AT incoming DOT verizon DOT net> <20031103163115 DOT GH18706 AT cygbert DOT vinschen DOT de> <20031103183956 DOT GA223527 AT Worldnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031103183956.GA223527@Worldnet> User-Agent: Mutt/1.4.1i On Mon, Nov 03, 2003 at 01:39:56PM -0500, Pierre A. Humblet wrote: > On Mon, Nov 03, 2003 at 05:31:15PM +0100, Corinna Vinschen wrote: > > On Sun, Nov 02, 2003 at 09:43:14AM -0500, Pierre A. Humblet wrote: > > > Pierre A. Humblet wrote: > > > > > > > The real problem is that the s_proto pointer of the struct servent > > > > returned by the Windows getservbyname on Win95 is invalid. > > > > > > Looking at net.cc, this problem seems to be well known. > > > However the workaround is only applied when copying the string, > > > not when computing its length. > > > > I see. I'll create a patch. > > I started one already, must still compile and test. > Let me know if you proceed on your side. I have a patch ready and it seems to work fine(tm). Would you mind to give it a try on 95? Patch below. Corinna Index: net.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/net.cc,v retrieving revision 1.154 diff -u -p -r1.154 net.cc --- net.cc 25 Sep 2003 00:37:17 -0000 1.154 +++ net.cc 3 Nov 2003 19:06:12 -0000 @@ -499,8 +499,21 @@ dup_ent (void *old, void *src0, struct_t /* Do servent/hostent specific processing */ int protolen = 0; int addr_list_len = 0; + char *s_proto = NULL; if (type == is_servent) - sz += (protolen = strlen_round (src->s_proto)); + { + if (src->s_proto) + { + /* Windows 95 idiocy. Structure is misaligned on Windows 95. + Kludge around this by trying a different pointer alignment. */ + if (IsBadReadPtr (src->s_proto, sizeof (src->s_proto)) + && !IsBadReadPtr (((pservent *) src)->s_proto, sizeof (src->s_proto))) + s_proto = ((pservent *) src)->s_proto; + else + s_proto = src->s_proto; + } + sz += (protolen = strlen_round (s_proto)); + } else if (type == is_hostent) { /* Calculate the length and storage used for h_addr_list */ @@ -549,16 +562,8 @@ dup_ent (void *old, void *src0, struct_t /* Do servent/hostent specific processing. */ if (type == is_servent) { - if (src->s_proto) + if (s_proto) { - char *s_proto; - /* Windows 95 idiocy. Structure is misaligned on Windows 95. - Kludge around this by trying a different pointer alignment. */ - if (IsBadReadPtr (src->s_proto, sizeof (src->s_proto)) - && !IsBadReadPtr (((pservent *) src)->s_proto, sizeof (src->s_proto))) - s_proto = ((pservent *) src)->s_proto; - else - s_proto = src->s_proto; strcpy (dst->s_proto = dp, s_proto); dp += protolen; } -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT cygwin DOT com Red Hat, Inc. -- 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/