Mail Archives: cygwin/2003/11/03/14:06:45
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/
- Raw text -