mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
Everywhere: Port to String::copy_characters_to_buffer()
This commit is contained in:
parent
be6cce5530
commit
852454746e
Notes:
sideshowbarker
2024-07-19 02:59:36 +09:00
Author: https://github.com/bugaevc
Commit: 852454746e
Pull-request: https://github.com/SerenityOS/serenity/pull/3296
Reviewed-by: https://github.com/BenWiederhake
Reviewed-by: https://github.com/alimpfard
8 changed files with 39 additions and 18 deletions
|
@ -112,13 +112,12 @@ bool Socket::connect(const SocketAddress& address)
|
|||
sockaddr_un saddr;
|
||||
saddr.sun_family = AF_LOCAL;
|
||||
auto dest_address = address.to_string();
|
||||
if (dest_address.length() >= sizeof(saddr.sun_path)) {
|
||||
bool fits = dest_address.copy_characters_to_buffer(saddr.sun_path, sizeof(saddr.sun_path));
|
||||
if (!fits) {
|
||||
fprintf(stderr, "Core::Socket: Failed to connect() to %s: Path is too long!\n", dest_address.characters());
|
||||
errno = EINVAL;
|
||||
return false;
|
||||
}
|
||||
strcpy(saddr.sun_path, address.to_string().characters());
|
||||
|
||||
m_destination_address = address;
|
||||
|
||||
return common_connect((const sockaddr*)&saddr, sizeof(saddr));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue