mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
UE: Make sure we return the right values for get{peer,sock}name
These two functions didn't previously return error codes correctly and would crash when an invalid address buffer was specified.
This commit is contained in:
parent
07341c3594
commit
52054eb922
Notes:
sideshowbarker
2024-07-18 17:57:48 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/52054eb9223 Pull-request: https://github.com/SerenityOS/serenity/pull/7173 Reviewed-by: https://github.com/awesomekling
1 changed files with 10 additions and 6 deletions
|
@ -714,9 +714,11 @@ int Emulator::virt$getsockname(FlatPtr params_addr)
|
|||
mmu().copy_from_vm(&addrlen, (FlatPtr)params.addrlen, sizeof(socklen_t));
|
||||
VERIFY(addrlen <= sizeof(addr));
|
||||
auto rc = getsockname(params.sockfd, (sockaddr*)&addr, &addrlen);
|
||||
mmu().copy_to_vm((FlatPtr)params.addr, &addr, sizeof(addr));
|
||||
mmu().copy_to_vm((FlatPtr)params.addrlen, &addrlen, sizeof(addrlen));
|
||||
return rc;
|
||||
if (rc == 0) {
|
||||
mmu().copy_to_vm((FlatPtr)params.addr, &addr, sizeof(addr));
|
||||
mmu().copy_to_vm((FlatPtr)params.addrlen, &addrlen, sizeof(addrlen));
|
||||
}
|
||||
return rc < 0 ? -errno : rc;
|
||||
}
|
||||
|
||||
int Emulator::virt$getpeername(FlatPtr params_addr)
|
||||
|
@ -728,9 +730,11 @@ int Emulator::virt$getpeername(FlatPtr params_addr)
|
|||
mmu().copy_from_vm(&addrlen, (FlatPtr)params.addrlen, sizeof(socklen_t));
|
||||
VERIFY(addrlen <= sizeof(addr));
|
||||
auto rc = getpeername(params.sockfd, (sockaddr*)&addr, &addrlen);
|
||||
mmu().copy_to_vm((FlatPtr)params.addr, &addr, sizeof(addr));
|
||||
mmu().copy_to_vm((FlatPtr)params.addrlen, &addrlen, sizeof(addrlen));
|
||||
return rc;
|
||||
if (rc == 0) {
|
||||
mmu().copy_to_vm((FlatPtr)params.addr, &addr, sizeof(addr));
|
||||
mmu().copy_to_vm((FlatPtr)params.addrlen, &addrlen, sizeof(addrlen));
|
||||
}
|
||||
return rc < 0 ? -errno : rc;
|
||||
}
|
||||
|
||||
int Emulator::virt$getgroups(ssize_t count, FlatPtr groups)
|
||||
|
|
Loading…
Reference in a new issue