Commit graph

1009 commits

Author SHA1 Message Date
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
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
3fc2c4866f LibC: Stub and test strlcpy 2020-08-24 00:45:03 +02:00
Ben Wiederhake
417ca7594b Tests: Remove unused include 2020-08-24 00:45:03 +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
Ben Wiederhake
4f77ccbda8 LibC+Userland: Prefer snprintf over sprintf
I ignored the sprintf in Userland/cal.cpp because it's too much trouble.
However, this only underlines the need for bounds checking.
2020-08-22 20:55:10 +02:00
Ben Wiederhake
499e953380 LibC: Demonstrate off-by-one in current snprintf
The function whose main selling point is that there always is a
NUL-terminator ... missed the NUL-terminator.
2020-08-22 20:55:10 +02:00
Nico Weber
96891669c3 test-js: Sometimes include more details for failures
LibJS doesn't store stacks for exception objects, so this
only amends test-common.js's __expect() with an optional
`details` function that can produce a more detailed error
message, and it lets test-js.cpp read and print that
error message.  I added the optional details parameter to
a few matchers, most notably toBe() where it now prints
expected and actual value.

It'd be nice to have line numbers of failures, but that
seems hard to do with the current design, and this is already
much better than the current state.
2020-08-22 10:52:40 +02:00
Nico Weber
3fbb02c3cc test-js: Print parse error if test-common.js fails to parse 2020-08-22 10:52:40 +02:00
asynts
aa25fb8875 Userland: Use TestSuite.h in test-compress. 2020-08-22 10:46:56 +02:00
AnotherTest
30554c969c LibLine: Handle interrupts/window size changes internally 2020-08-21 16:10:51 +02:00
asynts
8bbb7e25e6 LibCompress: Turn the DEFLATE implementation into a stream.
Previously, the implementation would produce one Vector<u8> which
would contain the whole decompressed data. That can be a lot and
even exhaust memory.

With these changes it is still necessary to store the whole input data
in one piece (I am working on this next,) but the output can be read
block by block. (That's not optimal either because blocks can be
arbitrarily large, but it's good for now.)
2020-08-20 16:28:31 +02:00
Luke
c2a2552e46 LibWeb: Add more document tests, add comment, text and mixin tests
Also adds a TypeScript definition file for the test runner object.
2020-08-17 22:57:05 +02:00
Andreas Kling
56c3748dcc LibWeb: Rename PageView => InProcessWebView 2020-08-17 18:05:35 +02:00
Andreas Kling
0fecdb7904 disasm: Use make<X86::ELFSymbolProvider> instead of naked new 2020-08-17 13:12:46 +02:00
Brian Gianforcaro
bcbac83a8b Userland: Explicitly ignore number of types read, found by Coverity 2020-08-17 09:17:57 +02:00
Ben Wiederhake
b0aa8115c2 Userland: Provide a misbehaving application
This will be a test case for #2977.
2020-08-17 00:01:13 +02:00
Nico Weber
f025204dfe disasm: For ELF inputs, pass an ELFSymbolProvider to disassembler
This lets disasm output contain the symbol names of call and jump
destinations:

    8048111:	e8 88 38 01 00       	call   805b99e <__cxa_atexit>
    ...
    8048150:	74 15                	je     8048167 <_start+0x4c>

The latter (the symbol of the current function with an offset) is
arguably more distracting than useful because you usually want to look
at the instruction at the absolute offset in this case, but the former
is very nice to have.

For reasons I do not understand, this cuts the time to run
`disasm /bin/id` in half, from ~1s to ~0.5s.
2020-08-16 19:37:58 +02:00
Ben Wiederhake
d33e3b7d8a LibCrypto: Fix random number generation 2020-08-16 16:35:23 +02:00
Ben Wiederhake
2e470a4a47 LibCrypto: Demonstrate that primality and random numbers are broken 2020-08-16 16:35:23 +02:00
Nico Weber
1e2dc736e3 Userland/tt: Switch to MiB 2020-08-16 16:33:28 +02:00
Nico Weber
43a0ffe54d Userland/allocate: Switch to KiB/MiB 2020-08-16 16:33:28 +02:00
Nico Weber
aa97166739 Everywhere: Consolidate human_readable_size() implementations
Let's use the one in AK/NumberFormat.h everywhere.

It has slightly different behavior than some of the copies this
removes, but it's probably nice to have uniform human readable
size outputs across the system.
2020-08-16 16:33:28 +02:00
Nico Weber
430b265cd4 AK: Rename KB, MB, GB to KiB, MiB, GiB
The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9".
The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30".

Let's use the correct name, at least in code.

Only changes the name of the constants, no other behavior change.
2020-08-16 16:33:28 +02:00
asynts
fc276946fb Refactor: Use ReadonlyBytes instead of const ReadonlyBytes&. 2020-08-15 21:21:18 +02:00
asynts
fff581cd72 AK: Rename span() to bytes() when appropriate.
I originally defined the bytes() method for the String class, because it
made it obvious that it's a span of bytes instead of span of characters.

This commit makes this more consistent by defining a bytes() method when
the type of the span is known to be u8.

Additionaly, the cast operator to Bytes is overloaded for ByteBuffer and
such.
2020-08-15 21:21:18 +02:00
Linus Groh
2e5c434e22 Misc: Use automatic window positioning in more applications
This is a follow up to #2936 / d3e3b4ae56aa79d9bde12ca1f143dcf116f89a4c.

Affected programs:
- Applications: Browser (Download, View source, Inspect DOM tree, JS
  console), Terminal (Settings)
- Demos: Cube, Eyes, Fire, HelloWorld, LibGfxDemo, WebView,
  WidgetGallery
- DevTools: HackStudio, Inspector, Profiler
- Games: 2048, Minesweeper, Snake, Solitaire
- Userland: test-web

A few have been left out where manual positioning is done on purpose,
e.g. ClipboardManager (to be close to the menu bar) or VisualBuilder (to
preserve alignment of the multiple application windows).
2020-08-15 17:38:19 +02:00
Andreas Kling
bbe2d4a2d9 LibJS+LibWeb: Clear exceptions after call'ing JavaScript functions
Decorated Interpreter::call() with [[nodiscard]] to provoke thinking
about the returned value at each call site. This is definitely not
perfect and we should really start thinking about slimming down the
public-facing LibJS interpreter API.

Fixes #3136.
2020-08-14 17:31:07 +02:00
Nico Weber
19b329ee96 ifconfig: Fix capitalization of "kiB" 2020-08-14 16:09:58 +02:00
Nico Weber
a2b99dd3ea disasm: Print correct offset-relative jumps in ELF file disassembly 2020-08-14 10:29:41 +02:00
Ben Wiederhake
76da9a4a7d Test: Mark compilation-unit-only functions as static
This enables a nice warning in case a function becomes dead code. Also,
in the case of test-crypto.cpp, I took the liberty to add the prefix 'g_'
to the global event loop.
2020-08-12 20:40:59 +02:00
Ben Wiederhake
0248ddc427 Userland: Mark compilation-unit-only functions as static
This enables a nice warning in case a function becomes dead code.
2020-08-12 20:40:59 +02:00
Linus Groh
7072806234 Meta: Replace remaining LibM/math.h includes with math.h 2020-08-12 16:18:33 +02:00
Ben Wiederhake
9abac64333 Userland: Make 'tt t' spawn a thread and stand still
This is useful to test SystemMonitor and /proc, because all other multi-threaded
processes tend to be moving targets.
2020-08-12 11:28:45 +02:00
AnotherTest
bc7a149039 LibCrypto+LibTLS+Kernel: Switch the Cipher::Mode interface to use Span
This shaves 2.5 more runtime seconds off 'disasm /bin/id', and makes the
Mode<T> interface a lot more allocation-friendly.
2020-08-11 21:37:10 +02:00
Andreas Kling
9e55162e9b mv: Accept (but ignore) -f
Many scripts seem to use "mv -f", so let's support that.
2020-08-11 20:29:14 +02:00
Andreas Kling
2a765ad062 rm: Implement a basic -f mode 2020-08-11 20:29:14 +02:00
Andreas Kling
015c8d0eb6 Userland: Add a simple dirname(1) utility 2020-08-10 21:20:28 +02:00
Ben Wiederhake
f225321184 Kernel: Demonstrate kill's pid/tid confusion bug 2020-08-10 11:51:45 +02:00
Ben Wiederhake
7ab90e1a13 Kernel: Demonstrate setpgid confusion bug
Technically, this can be 'exploited' to set the pgid of an exploiting process
to a near-arbitrary new pgid. This can cause conflicts when assigning future pgids,
destroys the session-boundary, and might confuse future pgid-to-session lookups.

In practice, I can't come up with a way that this causes actual harm.
2020-08-10 11:51:45 +02:00
Nico Weber
6613a4cb8c disasm: Insert symbol names in disassembly stream
The symbol name insertion scheme is different from objdump -d's.
Compare the output on Build/Userland/id:

* disasm:

        ...
        _start (08048305-0804836b):
        08048305  push ebp
        ...
        08048366  call 0x0000df56

        0804836b  o16 nop
        0804836d  o16 nop
        0804836f  nop

        (deregister_tm_clones (08048370-08048370))

        08048370  mov eax, 0x080643e0
        ...
        _ZN2AK8Utf8ViewC1ERKNS_6StringE (0805d9b2-0805d9b7):
        _ZN2AK8Utf8ViewC2ERKNS_6StringE (0805d9b2-0805d9b7):
        0805d9b2  jmp 0x00014ff2

        0805d9b7  nop

* objdump -d:

        08048305 <_start>:
         8048305:	55                   	push   %ebp
        ...
         8048366:	e8 9b dc 00 00       	call   8056006 <exit>
         804836b:	66 90                	xchg   %ax,%ax
         804836d:	66 90                	xchg   %ax,%ax
         804836f:	90                   	nop

        08048370 <deregister_tm_clones>:
         8048370:	b8 e0 43 06 08       	mov    $0x80643e0,%eax
        ...
        0805d9b2 <_ZN2AK8Utf8ViewC1ERKNS_6StringE>:
         805d9b2:	e9 eb f6 ff ff       	jmp    805d0a2 <_ZN2AK10StringViewC1ERKNS_6StringE>
         805d9b7:	90                   	nop

Differences:

1. disasm can show multiple symbols that cover the same instructions.
   I've only seen this happen for C1/C2 (and D1/D2) ctor/dtor pairs,
   but it could conceivably happen with ICF as well.

2. disasm separates instructions that do not belong to a symbol with
   a newline, so that nop padding isn't shown as part of a function
   when it technically isn't.

3. disasm shows symbols that are skipped (due to having size 0)
   in parenthesis, separated from preceding and following instructions.
2020-08-10 11:48:10 +02:00
Nico Weber
9c136be08b disasm: For ELF files, disassemble .text section
Since disasm is built in lagom, this requires adding LibELF to lagom.
2020-08-09 21:12:54 +02:00
AnotherTest
7ebba7bf3c open: Resolve the realpath before passing it to URL()
...which runs it through LexicalPath.
Fixes #3016.
2020-08-08 11:58:57 +02:00
Linus Groh
d9de0a5007 Userland: Use Core::ArgsParser for 'aplay' 2020-08-06 20:41:13 +02:00
Linus Groh
8f33a44b6c Userland: Use Core::ArgsParser for 'avol' 2020-08-06 20:41:13 +02:00
Linus Groh
9b07defb36 Userland: Use Core::ArgsParser for 'basename' 2020-08-06 20:41:13 +02:00