Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IPCHLE for gethostbyname. #2196

Merged
merged 1 commit into from Mar 17, 2015

Conversation

magumagu
Copy link
Contributor

@magumagu magumagu commented Mar 9, 2015

It turns out that the offsets of the data in the return buffer matter: the
offset 0x340 is hardcoded into the code that uses the result.

With that fixed, get rid of the completely wrong 0x80000000 hack.

Thanks @tueidj for pointing out how this is supposed to work.

@ghost
Copy link

ghost commented Mar 9, 2015

Couple of other minor things:

  • I'm not sure if they half-assed the implementation of aliases and no-one noticed because they're not used, or the address and alias pointers are meant to be one continuous NULL terminated list. The PPC code seems to think they're one list, which would mean detecting the number of addresses returned should require measuring the distance between h_addr_list and h_aliases instead of looking for the NULL.
  • the maximum number of combined aliases and addresses returned is 71; (0x460 - 0x340) / sizeof(void*) = 72, minus one for the terminator entry. The output buffer could be overflowed if a host has too many addresses.

// TODO: Fill this in? (Not that it's particularly useful...)
Memory::Write_U32(BufferOut + GETHOSTBYNAME_IP_PTR_LIST_OFFSET + num_ip_addr * 4, BufferOut + 4);
Memory::Write_U32(0, BufferOut + GETHOSTBYNAME_IP_PTR_LIST_OFFSET + num_ip_addr * 4 + 4);

This comment was marked as off-topic.

@magumagu
Copy link
Contributor Author

magumagu commented Mar 9, 2015

I'm guessing they half-assed the implementation; structure appears to be the Berkeley sockets hostent, which requires null-terminated lists.

@Sonicadvance1
Copy link
Contributor

+1 I like how it cleans up that mess of code

@magumagu
Copy link
Contributor Author

@dolphin-emu-bot rebuild

Updated to address review comments.

It turns out that the offsets of the data in the return buffer matter: the
offset 0x340 is hardcoded into the code that uses the result.

With that fixed, get rid of the completely wrong 0x80000000 hack.
skidau added a commit that referenced this pull request Mar 17, 2015
@skidau skidau merged commit b170173 into dolphin-emu:master Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants