Commit graph

4147 commits

Author SHA1 Message Date
Sergey Bugaev
1fb6a7d893 AK: Fix buffer overrun in Utf8CodepointIterator::operator++
The old implementation tried to move forward as long as the current
byte looks like a UTF-8 character continuation byte (has its two
most significant bits set to 10). This is correct as long as we assume
the string is actually valid UTF-8, which we do (we also have a separate
method that can check whether it is the case).

We can't, however, assume that the data after the end of our string
is also valid UTF-8 (in fact, we're not even allowed to look at data
outside out string, but it happens to a valid memory region most of
the time). If the byte after the end of our string also has its most
significant bits set to 10, we would move one byte forward, and then
fail the m_length > 0 assertion.

One way to fix this would be to add a length check inside the loop
condition. The other one, implemented in this commit, is to reimplement
the whole function in terms of decode_first_byte(), which gives us
the length as encoded in the first byte. This also brings it more
in line with the other functions around it that do UTF-8 decoding.
2019-09-08 17:45:10 +02:00
Andreas Kling
e386579436 Kernel: Fix bitrotted code behind #ifdef SIGNAL_DEBUG 2019-09-08 14:29:59 +02:00
Andreas Kling
31ba7ba2cc LibC: #define errno errno
This makes the binutils port build again, after the TLS changes.
2019-09-08 14:20:13 +02:00
Andreas Kling
23eafdb8d6 Kernel: waitpid() should unblock and -ECHILD if SIG_IGN reaps child 2019-09-08 14:01:00 +02:00
Conrad Pankoff
c983e96664 Kernel: Use timeval_sub for TCP retransmissions and lower timer to 500ms 2019-09-08 12:34:20 +02:00
Conrad Pankoff
3f1c3a341b Kernel: Handle listening socket disappearing during incoming handshake 2019-09-08 12:34:20 +02:00
Conrad Pankoff
feb6d1afe0 Kernel: Use a WeakPtr instead of a RefPtr for TCP socket originator 2019-09-08 12:34:20 +02:00
Conrad Pankoff
a2b61e30c5 Kernel: Put some network log messages behind debug flags 2019-09-08 12:34:20 +02:00
Conrad Pankoff
328d52b323 Kernel: Send ACK/FIN in response to FIN packets on active connections
This is to work around our lack of a shutdown() implementation.
2019-09-08 12:34:20 +02:00
Conrad Pankoff
117d8db2a2 Kernel: Implement outgoing TCP retransmission and better ACK handling
This approach is a bit naiive - whenever we send a packet out, we
check to see if there are any other packets we should try to send.
This works well enough for a busy connection but not very well for a
quiet one. Ideally we would check for not-acked packets on some kind
of timer, and use the length of this not-acked list as feedback to
throttle the writes coming from userspace.
2019-09-08 12:34:20 +02:00
Conrad Pankoff
b8e3c7ef01 Kernel: Remember all ARP replies, even ones we didn't request
This allows us to take advantage of unsolicited ARP replies, such as
those that are emitted by many systems after their network interfaces
are enabled, or after their DHCP client sets their IP.

This also makes us a bit more vulnerable to ARP flooding, but we need
some kind of eviction strategy anyway, so we can deal with that later.
2019-09-08 12:34:20 +02:00
Conrad Pankoff
b45cfae7f4 Kernel: Don't mark incoming sockets as connected in NetworkTask
An incoming socket should only be considered connected after a
program has received it from accept(). Before that point, it's only
"half" open, and it might not ever actually be served to a program.

Socket::accept is where m_connected is correctly set.
2019-09-08 12:34:20 +02:00
Conrad Pankoff
72f728b0d6 Kernel: Hold socket back from accept() until it's fully set up 2019-09-08 12:34:20 +02:00
Conrad Pankoff
d53c9d4416 Kernel: Use RefPtr instead of SocketHandle for TCPSocket clients
Using a SocketHandle takes a lock on the socket, which we don't want
to do.
2019-09-08 12:34:20 +02:00
Conrad Pankoff
cfcb53fe77 Kernel: Don't set sequence manually; send_tcp_packet will do it 2019-09-08 12:34:20 +02:00
Conrad Pankoff
e8a10848b5 Kernel: Make sure IPv4Socket is marked as listening in listen() 2019-09-08 12:34:20 +02:00
Conrad Pankoff
706e04d340 Kernel: Don't increment ACK number without SYN, FIN, or data 2019-09-08 12:34:20 +02:00
Conrad Pankoff
749719b4d0 Kernel: Fix debug messages in IPv4Socket 2019-09-08 12:34:20 +02:00
Conrad Pankoff
040947ee47 TelnetServer: Implement basic telnet server
Fixes #407

Depends on #530 to run reliably.
2019-09-08 10:56:34 +02:00
Andreas Kling
423807d772 WindowServer: Don't transform quick far-apart clicks into double-clicks
We now require that the two clicks that make up a double-click be no
more than 4px apart.

This fixes the annoying behavior where you'd often get incorrect
double-click events on GUI widgets.
2019-09-08 10:16:33 +02:00
Andreas Kling
33e6cb8b80 Kernel: Remove spammy logging about absolute_path() on non-custodies 2019-09-08 09:37:28 +02:00
Andreas Kling
fb275c9442 FileManager: Make the tree view follow the path changes correctly
The left-side tree view was not following along when switching paths
via the right-side views. Hook this back up.
2019-09-08 09:08:50 +02:00
Conrad Pankoff
9273589c5e AK: Pad %b and %w to two and four places in printf 2019-09-08 08:49:29 +02:00
Andreas Kling
64b1e9deec GTreeView: Make double-clicking toggle openable items 2019-09-07 21:45:06 +02:00
Andreas Kling
2f5b2685af GModel: Remove selected_index() and set_selected_index()
This breaks GSortingProxyModel selection preservation across resorts.
I'm not yet sure how we're going to solve that, but it's going to have
to work a bit differently than before, since the model itself no longer
knows what's selected.

Selection is now managed by GModelSelection which allows us to select
any arbitrary number of items, and to have different selections in
different views onto the same model. Pretty sweet. :^)
2019-09-07 21:39:44 +02:00
Andreas Kling
6dec328af7 LibGUI+FileManager: Add GAbstractView::on_selection_change hook
This hook will be called whenever the view's selection changes somehow.
Use this in the FileManager to keep the left and right views in sync.
2019-09-07 21:35:04 +02:00
Andreas Kling
9d97781e37 FileManager: Port to using GModelSelection 2019-09-07 20:41:14 +02:00
Andreas Kling
fb18613e8a LibGUI: Convert various little things to GModelSelection
All the little things that were using the per-model seletion are now
moving over to GModelSelection.
2019-09-07 20:35:31 +02:00
Andreas Kling
d2d1a30d61 GListView: Switch to using GModelSelection to support multi-select 2019-09-07 20:31:11 +02:00
Andreas Kling
56c360591c GTreeView: Switch to using GModelSelection
We don't support multi-select in GTreeView yet. Some day though :^)
2019-09-07 20:15:33 +02:00
Andreas Kling
f8c0168adc IRCClient: Fix window selection after GModelSelection changes 2019-09-07 20:01:37 +02:00
Andreas Kling
55bae788f0 GDirectoryModel: No need to clear the selected index in open()
Now that the view manages selection instead of the model, it's not
something GDirectoryModel needs to worry about anymore.
2019-09-07 20:01:18 +02:00
Andreas Kling
9c1fa0bd51 SystemMonitor: Fix PID selection after GModelSelection changes 2019-09-07 19:59:03 +02:00
Andreas Kling
98a68c82bc GItemView: Make Ctrl+click toggle item selection on/off 2019-09-07 19:38:08 +02:00
Andreas Kling
a5e0242992 GTableView: Switch to using GModelSelection to support multi-select 2019-09-07 19:35:45 +02:00
Andreas Kling
b0f42ee672 GModelSelection: Add contains_row(int) and toggle(GModelIndex) 2019-09-07 19:33:58 +02:00
Andreas Kling
94b599e344 GItemView: Switch to using GModelSelection to support multi-select
This is really quite straightforward. Instead of using the GModel's
selected_index(), we now query/update the view's own GModelSelection.
2019-09-07 19:21:07 +02:00
Andreas Kling
82559e211d LibGUI: Add GModelSelection to help implementing multiple-select views
Each GAbstractView now has a GModelSelection backed by a simple
HashTable<GModelIndex>. When the selection changes somehow, the view
gets notified via the notify_selection_changed() callback.

In the future it will probably make sense to move to using some kind of
ranges as the internal representation instead.
2019-09-07 19:21:07 +02:00
Andreas Kling
19b69741ed GModelIndex: Add hash traits so we can make a HashTable<GModelIndex> 2019-09-07 19:21:07 +02:00
Andreas Kling
60cd3c093a LibDraw: Make sure we install libdraw.a so ports can link with -ldraw 2019-09-07 18:19:02 +02:00
Andreas Kling
29f58aef21 LibC: Add some missing pieces in inttypes.h 2019-09-07 18:18:43 +02:00
Andreas Kling
899233a925 Kernel: Handle running programs that don't have a TLS image
Programs without a PT_TLS header won't have a master TLS image for us
to copy, so we shouldn't try to copy the m_master_tls_region then.
2019-09-07 17:06:25 +02:00
Andreas Kling
a635619cc0 GTabWidget: Rename get_active_tab() => active_tab_index() 2019-09-07 16:57:26 +02:00
Andreas Kling
568936775f DisplayProperties: Fix build after AKString.h => String.h change 2019-09-07 16:57:03 +02:00
Aaron Malpas
fe1ab7989f cp: Implement directory copying
Recursive copying is only allowed if cp is called with the -r switch, ala POSIX.
2019-09-07 16:54:49 +02:00
Aaron Malpas
86415acd6a cp: Refactor copying into copy_file function 2019-09-07 16:54:49 +02:00
Aaron Malpas
4bc6c20091 cp: Use LibCore/CArgsParser for command-line arg parsing 2019-09-07 16:54:49 +02:00
Jesse Buhagiar
3f05799e41 LibGUI: GTabWidget can now return active tab index
`GTabWidget` now allows the user/caller to get the currently active
tab widget, meaning that actions that are applied globally (such as
an 'Apply' or 'OK' button) can now react to specific tabs etc.
2019-09-07 16:51:15 +02:00
Jesse Buhagiar
ecbc0322c1 Applications: Create a display properties manager
An interactive application to modify the current display settings, such as
the current wallpaper as well as the screen resolution. Currently we're
adding the resolutions ourselves, because there's currently no way to
detect was resolutions the current display adapter supports (or at least
I can't see one... Maybe VBE does and I'm stupid). It even comes with
a very nice template'd `ItemList` that can support a vector of any type,
which makes life much simpler.
2019-09-07 16:51:15 +02:00
Andreas Kling
af14b8dc59 LibC: Make "errno" thread-specific
Now that the kernel supports thread-local storage, we can declare errno
with the __thread keyword, which causes it to be per-thread.

This should fix all the stupid issues that happen when many threads use
the same errno. :^)
2019-09-07 15:57:02 +02:00