Commit graph

12532 commits

Author SHA1 Message Date
AnotherTest
5b5ba91335 AK: Add URL::create_with_data() to create data URLs 2020-08-24 18:21:33 +02:00
AnotherTest
e1a819827c LibGUI: Make AbstractTableView and TableView more customisable
This patchset adds a few getters/setters to AbstractTableView to make
its looks more customisable:
- Header width & text alignment
- Default column width
- Ability to disable selected row highlighting
2020-08-24 18:21:33 +02:00
Nico Weber
697faba147 LibJS: Make Date.getUTCSeconds() call through to LibC
The tzset documentation says that TZ allows a per-second local timezone,
so don't be needlessly clever here.

No observable behavior difference at this point, but if we ever
implement tzset, this will have a small effect.
2020-08-24 18:21:16 +02:00
Nico Weber
2191ec591f LibJS: Make Date's tuple constructor correctly handle out-of-range arguments
Milliseconds need extra handling, but everything else just works
now that mktime() handles this case.
2020-08-24 18:20:07 +02:00
Nico Weber
5b9d43767c LibCore: Make DateTime::create() and set_time() handle out-of-range values
Set member variables after calling mktime(), which canonicalizes
out-of-range values.

With this, DateTime::create(2020, 13, ...) will return a DateTime
on Jan 2021 (assuming the other parameters are in range).
2020-08-24 18:20:07 +02:00
Nico Weber
593b0b9fcc LibCore: Less code duplication in DateTime
DateTime::create() an just call DateTime::set_time().

No behavior change.
2020-08-24 18:20:07 +02:00
Nico Weber
1c9581f383 LibC: Make mktime() / gmtime() more POSIX-compliant
mktime() is supposed to fill in tm_wday and tm_yday, and it
it's supposed to canonicalize out-of-range values (that is,
"Jan 31" is turned into "Feb 1").

Instead of making the straightfoward tm_to_time() implementation
more complicated, just make it call time_to_tm() once the timestamp
is computed to break it back down ot (canonical) tm entries.
2020-08-24 18:20:07 +02:00
Nico Weber
84f729c2b4 LibJS+LibC: Add tests for Date tuple ctor overflow and make mktime()/timegm() handle month overflow 2020-08-24 09:30:11 +02:00
AnotherTest
465d46c665 Meta+Userland: Run the TLS test too
While this _does_ add a point of failure, it'll be a pretty bad day when
google goes down.
And this is unlikely to put a (positive) dent in their incoming
requests, so let's just roll with it until we have our own TLS server.
2020-08-24 09:29:39 +02:00
AnotherTest
c9f902d5de Userland: Add missing HMAC-SHA1 tests 2020-08-24 09:29:39 +02:00
AnotherTest
abb842ee5a LibTLS: Fix some debug logging 2020-08-24 09:29:39 +02:00
AnotherTest
0be3937be7 LibTLS: Do not process_message() the finished message twice
With two different sequence numbers to boot!
Fixes #3273
2020-08-24 09:29:39 +02:00
Ben Wiederhake
7a2b5d1328 Tests: Prefer strlcpy over strncpy
Because it looks nicer.
2020-08-24 00:45:03 +02:00
Ben Wiederhake
cb52bfdd27 Userland: Prefer strlcpy over strcpy in ping
This is supposed to serve as a reminder if and when someone decides to make
the 'msg' field configurable.
2020-08-24 00:45:03 +02:00
Ben Wiederhake
5c1a72f0ef Userland: Prefer strlcpy over strncpy in ifconfig, fixes off-by-one
A malicious caller of ifconfig could have caused the ifr_name field to
lack NUL-termination. I don't think this was an actual problem, though, as
the Kernel always forces NUL-termination by overwriting ifr_name's last byte
with NUL.

However, it feels better to do it properly.
2020-08-24 00:45:03 +02:00
Ben Wiederhake
46b04a79e5 DHCPClient: Prefer strlcpy over strncpy, fixes off-by-one
A malicious caller of set_params could have caused the ifr_name field to
lack NUL-termination. I don't think this was an actual problem, though, as
the Kernel always forces NUL-termination by overwriting ifr_name's last byte
with NUL.

However, it feels better to do it properly.

No behaviour change (probably).
2020-08-24 00:45:03 +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
Ben Wiederhake
d419a780ae LibC: Prefer strlcpy over strcpy/strncpy
All of these are cosmetic (I believe). Furthermore, they serve as
reminders to always check the length of the destination buffers.
2020-08-24 00:45:03 +02:00
Ben Wiederhake
aa36e9917c LibC: Prefer strlcpy over strcpy in getgrent(), fix overflow
An overlong group name in /etc/groups would have caused getgrent() to overflow
the global __grdb_entry. Curiously, overflow *within* __grdb_entry seems to have
no detrimental effects.

However, it was possible for a malicious sysadmin(?!) to craft an /etc/group
that overflows outside of the page allocated for __grdb_entry thus crash the
calling process. This affected at least SystemServer and su.

Now, the group name will be simply truncated. For display purposes, this is
fine. In case there is an exceptionally long group, it will not be properly
recognized. Also, a malicious /etc/groups might cause the caller of getgrent()
to become confused, but that is unavoidable.
2020-08-24 00:45:03 +02:00
Ben Wiederhake
9785173dec LibC: Fix strftime() for max_size=0
Before, strftime unintentionally interpreted 0 as 'unlimited'. The specification
of strftime says no such thing.

Now, it properly returns 0 in that case (because the NUL byte doesn't fit).
2020-08-24 00:45:03 +02:00
Ben Wiederhake
41b70ae8ba LibC: Implement strlcpy 2020-08-24 00:45:03 +02:00
Ben Wiederhake
3fc2c4866f LibC: Stub and test strlcpy 2020-08-24 00:45:03 +02:00
Ben Wiederhake
d5b7c28a5e Kernel: Remove strcpy()
These are not called in the kernel or by libstdc++ anyway.

Remove the tempting function, and prevent future overflows.
2020-08-24 00:45:03 +02:00
Ben Wiederhake
9795c61464 LibC: Prevent slowness and overrun in strdup/strndup
strdup: Because the length is already known at the time of copying, there is
no need to use strcpy (which has to check every single byte, and thus tends
to be slower than memcpy).

strndup: If 'str' is not NUL-terminated, strndup used to run off into the
adjacent memory region. This can be fixed by using the proper strlen variant:
strnlen.
2020-08-24 00:45:03 +02:00
Ben Wiederhake
2adc3c61a2 AK: Document that String{,Impl} contains NUL-terminator 2020-08-24 00:45:03 +02:00
Ben Wiederhake
417ca7594b Tests: Remove unused include 2020-08-24 00:45:03 +02:00
Ben Wiederhake
01dabb65f2 AK: Remove redundant declaration in String.cpp
It already includes AK/Memory.h, which includes Kernel/StdLib.h, which.
declares strstr().
2020-08-24 00:45:03 +02:00
Andreas Kling
638c6b7547 LibGUI: Fix an unsightly pixel glitch in bottom-side tabs 2020-08-24 00:05:40 +02:00
Andreas Kling
4eb1fd6ea3 SystemMonitor: Use bottom-side tabs for the per-process info tabs
Let's try this out and see how it feels! :^)
2020-08-23 23:53:45 +02:00
Andreas Kling
03c576acc5 LibGUI+LibGfx: Implement upside-down appearance for bottom-side tabs
GUI::TabWidget has long has a TabPosition::Bottom option, but we still
rendered the tab buttons the same as TabPosition::Top.

This patch implements a custom look for bottom-side tabs. I've done my
best to match the look of the top-side ones, but there might be some
improvements we can make here. :^)
2020-08-23 23:53:45 +02:00
Linus Groh
59172e2714 Base: Add ThemeEditor.af 2020-08-23 23:05:00 +02:00
Nico Weber
ad00462daa LibJS: Implement Date.getUTC*
Test files created with:
    $ for f in Libraries/LibJS/Tests/builtins/Date/Date.prototype.get*js; do
          cp $f $(echo $f | sed -e 's/get/getUTC/') ;
      done
    $ rm Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTCTime.js
    $ git add Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTC*.js
    $ ls Libraries/LibJS/Tests/builtins/Date/Date.prototype.getUTC*.js | \
          xargs sed -i -e 's/get/getUTC/g'
2020-08-23 22:00:05 +02:00
Nico Weber
d5eaefe87b LibJS: Move datetime access out of DatePrototype
How Date keeps time internally should be an implementation detail
of Date, so move it behind accessors.

No behavior change.
2020-08-23 22:00:05 +02:00
AnotherTest
f0ef283f3c LibLine: Correct weird arrow up/down behaviour
Fixes #3270.
Also removes a parameter from search(), as it had no effect.
2020-08-23 15:36:11 +02:00
Muhammad Zahalqa
7506adbece
Kernel: Avoid some allocations in command line parsing (#3213)
1. Preallocate args hashmap to prevent rehashing.
2. Use move to prevent string copies.
2020-08-23 15:04:49 +02:00
Andreas Kling
1b075ffe3b ThemeEditor: Paint the minimize/maximize/close window button icons 2020-08-23 15:02:44 +02:00
Andreas Kling
26cc733f93 ThemeEditor: Add window buttons (no bitmaps yet) 2020-08-23 14:58:15 +02:00
Andreas Kling
690c736c3a ThemeEditor: Add a handful of widgets to the preview
This needs to be spruced up a bit, but having a set of common widgets
gives you a quick idea of what the theme will look like. :^)
2020-08-23 14:12:42 +02:00
Andreas Kling
85e818206c LibGfx+WindowServer: Simplify notification window frame theming
Don't require theme clients to provide the frame rect, the theme can
compute that internally based on the window rect.
2020-08-23 13:17:34 +02:00
Ben Wiederhake
0944f56181 AK: Fix human_readable_size corner cases
In particular: consistent rounding and extreme values.

Before, rounding was something like 'away from 0.999...', which led to
surprising corner cases in which the value was rounded up.

Now, rounding is always 'down'.
This even works for 0xffffffff, and also for 0xffffffffffffffffULL on 64-bit.
2020-08-23 11:24:55 +02:00
Ben Wiederhake
f697d35fb1 AK: Add tests for human_readable_size() 2020-08-23 11:24:55 +02:00
Ben Wiederhake
53abc626c2 AK: Print RHS and LHS in EXPECT_EQ if we can
This makes error messages more useful during debugging.

Old:

    START Running test compare_views
    FAIL: ../AK/Tests/TestStringView.cpp:59: EXPECT_EQ(view1, "foobar") failed

New:

    START Running test compare_views
    FAIL: ../AK/Tests/TestStringView.cpp:59: EXPECT_EQ(view1, "foobar") failed: LHS="foo", RHS="foobar"
2020-08-23 11:24:55 +02:00
Luke
bedd15c340 test-web: Add updates from test-js
These should definitely be deduplicated at some point.
2020-08-23 11:22:47 +02:00
Luke
5877d6713c test-js+test-web: Clear taskbar progress on error/assertion failure
Closes #3240
2020-08-23 11:22:47 +02:00
thankyouverycool
f88b2b064c LibGUI: Remove spacing between day labels in Calendar
Provides better centering over columns.
2020-08-23 11:22:21 +02:00
Nico Weber
5f595e7e1b LibC: Make localtime() and gmtime() handle years before 1970
Year computation has to be based on seconds, not days, in case
t is < 0 but t / __seconds_per_day is 0.

Year computation also has to consider negative timestamps.

With this, days is always positive and <= the number of days in the
year, so base the tm_wday computation directly on the timestamp,
and do it first, before t is modified in the year computation.
In C, % can return a negative number if the left operand is negative,
compensate for that.

Tested via test-js. (Except for tm_wday, since we don't implement
Date.prototype.getUTCDate() yet.)
2020-08-23 10:42:37 +02:00
Nico Weber
fc28c9b085 LibC: Slightly tweak tm_to_time
Only one of these loops runs even without the outer if, so omit it.
No behavior change, and a bit shorter and arguably a bit clearer.
2020-08-23 10:42:37 +02:00
Nico Weber
cec467fe35 LibJS: Enable Date.parse.js tests that pass after c399caf27f 2020-08-23 10:42:37 +02:00
Emanuele Torre
553889b2f5 ThemeEditor: Use m_inactive_window_icon when painting the inactive..
..window

`m_inactive_window_icon` wasn't being used.
2020-08-23 10:20:52 +02:00
Andreas Kling
31d3eac651 Ext2FS: Fix build with EXT2_DEBUG 2020-08-23 01:25:29 +02:00