mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibCore: fix UDP Server receive to trim buffer to actuall bytes receiveed
This commit is contained in:
parent
d9470bdae7
commit
043d548b39
Notes:
sideshowbarker
2024-07-19 04:08:17 +09:00
Author: https://github.com/tryfinally Commit: https://github.com/SerenityOS/serenity/commit/043d548b391 Pull-request: https://github.com/SerenityOS/serenity/pull/3045 Reviewed-by: https://github.com/elcuco
1 changed files with 3 additions and 1 deletions
|
@ -79,13 +79,15 @@ bool UDPServer::bind(const IPv4Address& address, u16 port)
|
|||
|
||||
ByteBuffer UDPServer::receive(size_t size, sockaddr_in& in)
|
||||
{
|
||||
auto buf = ByteBuffer::create_zeroed(size);
|
||||
auto buf = ByteBuffer::create_uninitialized(size);
|
||||
socklen_t in_len = sizeof(in);
|
||||
ssize_t rlen = ::recvfrom(m_fd, buf.data(), size, 0, (sockaddr*)&in, &in_len);
|
||||
if (rlen < 0) {
|
||||
dbg() << "recvfrom: " << strerror(errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
buf.trim(rlen);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue