Commit graph

16 commits

Author SHA1 Message Date
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
asynts
a410bb8fd5 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:49:29 +01:00
Andreas Kling
5f182746b6 LibCore: Stop logging that a Core::Socket has disconnected in receive()
This is perfectly normal and nothing we need to inform about.
2020-12-23 15:45:59 +01:00
Conrad Pankoff
bb4e4921c0 LibCore: Expose some Socket properties to make then inspectable 2020-12-16 17:12:13 +01:00
Sergey Bugaev
852454746e Everywhere: Port to String::copy_characters_to_buffer() 2020-08-30 17:35:27 +02:00
Ben Wiederhake
e682967d7e LibCore: Prefer strlcpy over strncpy, fix overflow
A malicious caller can create a SocketAddress for a local unix socket with an
over-long name that does not fit into struct sock_addr_un.
- Socket::connet: This caused the 'sun_path' field to
  overflow, probably overwriting the return pointer of the call frame, and thus
  crashing the process (in the best case).
- SocketAddress::to_sockaddr_un: This triggered a RELEASE_ASSERT, and thus
  crashing the process.

Both have been fixed to return a nice error code instead of crashing.
2020-08-24 00:45:03 +02:00
asynts
21de20825a LibCore: Change the signature of Socket::send() to use Span. 2020-07-27 19:58:09 +02:00
Andreas Kling
41066b009f LibCore: Don't fire Socket::on_ready_to_read if !can_read()
This is a bit of a pickle and I'm unsure what's the best behavior here.

Since notifiers fire asynchronously via the event loop, we may end up
firing a notifier for a socket fd, but then reading/writing that socket
fd before ending up in the notifier callback.

In that situation, the socket is no longer in the same state as it was
when the event loop generated the notifier event.

This patch stops Socket from firing one hook in this situation but this
probably needs a global rethink.

With this change, Browser starts reliably in multi-process mode. :^)
2020-07-06 23:17:10 +02:00
Sergey Bugaev
89004a3a40 LibCore: Make sure to disable notifiers when closing a socket
RefPtr<Notifier> doesn't work quite like it appears to, since the notifier
is also a "child" of the socket, in Core::Object sense. Thus we have to both
remove it from the parent (socket) and drop the additional RefPtr<Notifier> for
it to actually go away.

A proper fix for this would be to untangle parent-child relashionship from
refcounting and inspectability.

This fixes use-after-close of client file descriptors in IPC servers.
2020-06-08 13:58:32 +02:00
Andreas Kling
4b202a3c79 LibCore+LibTLS: Don't keep a "ready to write" notifier on all Sockets
The "ready to write" notifier we set up in generic socket connection is
really only meant to detect a successful connection. Once we have a TCP
connection, for example, it will fire on every event loop iteration.

This was causing IRC Client to max out the CPU by getting this no-op
notifier callback over and over.

Since this was only used by TLSv12, I changed that code to create its
own notifier instead. It might be possible to improve TLS performance
by only processing writes when actually needed, but I didn't look very
closely at that for this patch. :^)
2020-05-18 20:16:52 +02:00
AnotherTest
7eb72c72e8 LibCore: Mark Socket::{common_,}connect() virtual and add a on_write 2020-05-02 12:24:10 +02:00
Andreas Kling
28f1486627 LibCore: Log a more helpful message when Socket::connect() fails
Fixes #1272.
2020-02-22 16:41:31 +01:00
Andreas Kling
88b9fcb976 AK: Use size_t for ByteBuffer sizes
This matches what we already do for string types.
2020-02-20 13:20:34 +01:00
Andreas Kling
8f7333f080 LibCore: Add a forward declaration header
This patch adds <LibCore/Forward.h> and uses it in various places to
shrink the header dependency graph.
2020-02-14 23:31:18 +01:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00
Renamed from Libraries/LibCore/CSocket.cpp (Browse further)