Hi,
I was having a problem with a game, it couldn't connect to the server, so I
started debugging things, and it ofcourse brought me to dlls/winsock.c but
the problem seems to be on the game side ( unfortunately its closed-source,
so I can only guess what's happening ).
The debugging showed that when the game was getting server's ip from
DNS (WS_gethostbyname()), it was getting wrong values. Then I started looking
for the cause, and I found out that the game was incorrectly reading the
hostent/WS_hostent structure. It was assuming that the ip address was at
particular offset from the beginning of the structure, it didn't follow the
pointers and thus it was getting wrong data. Then I rewrote few lines of the
code and now it looks like:
"pointer | pointer | pointer | ... data | data | data | .... "
and everything works fine. So I assume that Microsoft's winsock arrange this
structure this way, but I am not sure if it is 100% compatible way solving
"one application problem", although few other programs dependent on this
function worked fine with this change. Anyway I left the topic with question
mark because I would like to know someone else's opinion on that.
( btw. I am new to mailing lists and it is my first post, so please don't be
too rough on me in your responses : )
Index: dlls/winsock/socket.c
===================================================================
RCS file: /home/wine/wine/dlls/winsock/socket.c,v
retrieving revision 1.188
diff -u -p -r1.188 socket.c
--- dlls/winsock/socket.c 25 Aug 2005 10:22:12 -0000 1.188
+++ dlls/winsock/socket.c 25 Aug 2005 22:20:58 -0000
@@ -3343,16 +3343,16 @@ static struct WS_hostent *WS_dup_he(cons
p_to->h_addrtype = p_he->h_addrtype;
p_to->h_length = p_he->h_length;
- p = (char *)(p_to + 1);
+ p = (char *)p_to + sizeof(struct hostent);
+ p_to->h_addr_list = (char **)p;
+ p += list_dup(p_he->h_addr_list, p_to->h_addr_list, p_he->h_length);
+
p_to->h_name = p;
- strcpy(p, p_he->h_name);
- p += strlen(p) + 1;
+ strcpy(p_to->h_name, p_he->h_name);
+ p += strlen(p_he->h_name) + 1;
p_to->h_aliases = (char **)p;
- p += list_dup(p_he->h_aliases, p_to->h_aliases, 0);
-
- p_to->h_addr_list = (char **)p;
- list_dup(p_he->h_addr_list, p_to->h_addr_list, p_he->h_length);
+ list_dup(p_he->h_aliases, p_to->h_aliases, 0);
return p_to;
}