1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

Net: Fix initializing sockaddr_un.sun_path copy buffers

The whole point of allocating an extra byte for the null terminator
is to initialize it to zero.
This commit is contained in:
Sergey Bugaev 2019-08-10 18:49:14 +03:00 committed by Andreas Kling
parent 43ce6c5474
commit 908068d19d

View file

@ -48,7 +48,7 @@ KResult LocalSocket::bind(const sockaddr* address, socklen_t address_size)
return KResult(-EINVAL);
const sockaddr_un& local_address = *reinterpret_cast<const sockaddr_un*>(address);
char safe_address[sizeof(local_address.sun_path) + 1];
char safe_address[sizeof(local_address.sun_path) + 1] = { 0 };
memcpy(safe_address, local_address.sun_path, sizeof(local_address.sun_path));
#ifdef DEBUG_LOCAL_SOCKET
@ -81,7 +81,7 @@ KResult LocalSocket::connect(FileDescription& description, const sockaddr* addre
return KResult(-EINVAL);
const sockaddr_un& local_address = *reinterpret_cast<const sockaddr_un*>(address);
char safe_address[sizeof(local_address.sun_path) + 1];
char safe_address[sizeof(local_address.sun_path) + 1] = { 0 };
memcpy(safe_address, local_address.sun_path, sizeof(local_address.sun_path));
#ifdef DEBUG_LOCAL_SOCKET