summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/net.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-11-03 21:43:32 +0000
committerCorinna Vinschen <corinna@vinschen.de>2003-11-03 21:43:32 +0000
commitdff017b292aab890b95db9574460801be3fea8ac (patch)
treeea15e80a53158eeff382899f5f935f2affcf7182 /winsup/cygwin/net.cc
parent79c5244017ff679a1fb0087db1a1e36c2fd15d5a (diff)
downloadcygnal-dff017b292aab890b95db9574460801be3fea8ac.tar.gz
cygnal-dff017b292aab890b95db9574460801be3fea8ac.tar.bz2
cygnal-dff017b292aab890b95db9574460801be3fea8ac.zip
* net.cc (dup_ent): Move Win 95 misalignment recogition before
trying to evaluate string length.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 7b09751f6..f956cbd8f 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -499,8 +499,21 @@ dup_ent (void *old, void *src0, struct_type type)
/* 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_type type)
/* 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;
}