mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 23:58:40 +00:00
netctl: Add null check for gethostbyname output. (#1468)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
This commit is contained in:
parent
9ec75c3feb
commit
0b015daff7
1 changed files with 9 additions and 8 deletions
|
@ -170,14 +170,15 @@ int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
|
||||||
"127.0.0.1"); // placeholder in case gethostbyname can't find another ip
|
"127.0.0.1"); // placeholder in case gethostbyname can't find another ip
|
||||||
char devname[80];
|
char devname[80];
|
||||||
gethostname(devname, 80);
|
gethostname(devname, 80);
|
||||||
struct hostent* resolved = gethostbyname(devname);
|
if (struct hostent* resolved = gethostbyname(devname)) {
|
||||||
for (int i = 0; resolved->h_addr_list[i] != nullptr; ++i) {
|
for (int i = 0; resolved->h_addr_list[i] != nullptr; ++i) {
|
||||||
struct in_addr addrIn;
|
struct in_addr addrIn;
|
||||||
memcpy(&addrIn, resolved->h_addr_list[i], sizeof(u32));
|
memcpy(&addrIn, resolved->h_addr_list[i], sizeof(u32));
|
||||||
char* addr = inet_ntoa(addrIn);
|
char* addr = inet_ntoa(addrIn);
|
||||||
if (strcmp(addr, "127.0.0.1") != 0) {
|
if (strcmp(addr, "127.0.0.1") != 0) {
|
||||||
strcpy(info->ip_address, addr);
|
strcpy(info->ip_address, addr);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue