Author: tfaber
Date: Wed Jan 25 00:12:18 2012
New Revision: 55162
URL:
http://svn.reactos.org/svn/reactos?rev=55162&view=rev
Log:
[WS2_32]
- Fix invalid AQ_WIN16 comparisons. Spotted by you-know-what. Fix taken from Wine.
Modified:
trunk/reactos/dll/win32/ws2_32/misc/async.c
Modified: trunk/reactos/dll/win32/ws2_32/misc/async.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/misc/asyn…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/misc/async.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/misc/async.c [iso-8859-1] Wed Jan 25 00:12:18 2012
@@ -200,23 +200,31 @@
WS_hostent *p_to32 = (WS_hostent*)p_to;
int size = hostent_size(p_he) +
(
- (flag & AQ_WIN16) ? sizeof(struct ws_hostent16) : sizeof(WS_hostent)
+ (flag & AQ_WIN32) ? sizeof(WS_hostent) : sizeof(struct ws_hostent16)
- sizeof(struct hostent)
);
if (t_size < size)
return -size;
p = p_to;
- p += (flag & AQ_WIN16) ?
- sizeof(struct ws_hostent16) : sizeof(WS_hostent);
+ p += (flag & AQ_WIN32) ?
+ sizeof(WS_hostent) : sizeof(struct ws_hostent16);
p_name = p;
strcpy(p, p_he->h_name); p += strlen(p) + 1;
p_aliases = p;
- p += list_dup(p_he->h_aliases, p, p_base + (p - (char*)p_to), 0);
+ p += list_dup(p_he->h_aliases, p, p_base + (p - p_to), 0);
p_addr = p;
- list_dup(p_he->h_addr_list, p, p_base + (p - (char*)p_to), p_he->h_length);
-
- if (flag & AQ_WIN16)
+ list_dup(p_he->h_addr_list, p, p_base + (p - p_to), p_he->h_length);
+
+ if (flag & AQ_WIN32)
+ {
+ p_to32->h_addrtype = p_he->h_addrtype;
+ p_to32->h_length = p_he->h_length;
+ p_to32->h_name = (p_base + (p_name - p_to));
+ p_to32->h_aliases = (char **)(p_base + (p_aliases - p_to));
+ p_to32->h_addr_list = (char **)(p_base + (p_addr - p_to));
+ }
+ else
{
p_to16->h_addrtype = (INT16)p_he->h_addrtype;
p_to16->h_length = (INT16)p_he->h_length;
@@ -224,14 +232,6 @@
p_to16->h_aliases = (SEGPTR)(p_base + (p_aliases - p_to));
p_to16->h_addr_list = (SEGPTR)(p_base + (p_addr - p_to));
}
- else
- {
- p_to32->h_addrtype = p_he->h_addrtype;
- p_to32->h_length = p_he->h_length;
- p_to32->h_name = (p_base + (p_name - p_to));
- p_to32->h_aliases = (char **)(p_base + (p_aliases - p_to));
- p_to32->h_addr_list = (char **)(p_base + (p_addr - p_to));
- }
return size;
}
@@ -258,31 +258,30 @@
WS_protoent *p_to32 = (WS_protoent*)p_to;
int size = protoent_size(p_pe) +
(
- (flag & AQ_WIN16) ? sizeof(struct ws_protoent16) : sizeof(WS_protoent)
+ (flag & AQ_WIN32) ? sizeof(WS_protoent) : sizeof(struct ws_protoent16)
- sizeof(struct protoent)
);
if (t_size < size)
return -size;
p = p_to;
- p += (flag & AQ_WIN16) ?
- sizeof(struct ws_protoent16) : sizeof(WS_protoent);
+ p += (flag & AQ_WIN32) ? sizeof(WS_protoent) : sizeof(struct ws_protoent16);
p_name = p;
strcpy(p, p_pe->p_name); p += strlen(p) + 1;
p_aliases = p;
- list_dup(p_pe->p_aliases, p, p_base + (p - (char*)p_to), 0);
-
- if (flag & AQ_WIN16)
+ list_dup(p_pe->p_aliases, p, p_base + (p - p_to), 0);
+
+ if (flag & AQ_WIN32)
+ {
+ p_to32->p_proto = p_pe->p_proto;
+ p_to32->p_name = (p_base) + (p_name - p_to);
+ p_to32->p_aliases = (char **)((p_base) + (p_aliases - p_to));
+ }
+ else
{
p_to16->p_proto = (INT16)p_pe->p_proto;
p_to16->p_name = (SEGPTR)(p_base) + (p_name - p_to);
p_to16->p_aliases = (SEGPTR)((p_base) + (p_aliases - p_to));
- }
- else
- {
- p_to32->p_proto = p_pe->p_proto;
- p_to32->p_name = (p_base) + (p_name - p_to);
- p_to32->p_aliases = (char **)((p_base) + (p_aliases - p_to));
}
return size;
@@ -312,15 +311,14 @@
WS_servent *p_to32 = (WS_servent*)p_to;
int size = servent_size(p_se) +
(
- (flag & AQ_WIN16) ? sizeof(struct ws_servent16) : sizeof(WS_servent)
+ (flag & AQ_WIN32) ? sizeof(WS_servent) : sizeof(struct ws_servent16)
- sizeof(struct servent)
);
if (t_size < size)
return -size;
p = p_to;
- p += (flag & AQ_WIN16) ?
- sizeof(struct ws_servent16) : sizeof(WS_servent);
+ p += (flag & AQ_WIN32) ? sizeof(WS_servent) : sizeof(struct ws_servent16);
p_name = p;
strcpy(p, p_se->s_name); p += strlen(p) + 1;
p_proto = p;
@@ -328,19 +326,19 @@
p_aliases = p;
list_dup(p_se->s_aliases, p, p_base + (p - p_to), 0);
- if (flag & AQ_WIN16)
+ if (flag & AQ_WIN32)
+ {
+ p_to32->s_port = p_se->s_port;
+ p_to32->s_name = (p_base + (p_name - p_to));
+ p_to32->s_proto = (p_base + (p_proto - p_to));
+ p_to32->s_aliases = (char **)(p_base + (p_aliases - p_to));
+ }
+ else
{
p_to16->s_port = (INT16)p_se->s_port;
p_to16->s_name = (SEGPTR)(p_base + (p_name - p_to));
p_to16->s_proto = (SEGPTR)(p_base + (p_proto - p_to));
p_to16->s_aliases = (SEGPTR)(p_base + (p_aliases - p_to));
- }
- else
- {
- p_to32->s_port = p_se->s_port;
- p_to32->s_name = (p_base + (p_name - p_to));
- p_to32->s_proto = (p_base + (p_proto - p_to));
- p_to32->s_aliases = (char **)(p_base + (p_aliases - p_to));
}
return size;