Commit Graph

294 Commits

Author SHA1 Message Date
Luke
3e723ec177 LibTTF: Check if the given offset plus offset table size would overflow
If it does overflow, it would think there was enough data to read in
table information, when there isn't. This would cause read buffer
overflows when reading in the table information.

Found by: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29338&sort=-opened&can=1&q=proj%3Aserenity
2021-02-08 18:01:41 +01:00
Linus Groh
83c29bd8d7 LibJS: Don't assume match for each capture group in RegExp.prototype.exec()
This was not implementing the following part of the spec correctly:

    27. For each integer i such that i ≥ 1 and i ≤ n, do
        a. Let captureI be ith element of r's captures List.
        b. If captureI is undefined, let capturedValue be undefined.

Expecting a capture group match to exist for each of the RegExp's
capture groups would assert in Vector's operator[] if that's not the
case, for example:

    /(foo)(bar)?/.exec("foo")

Append undefined instead.

Fixes #5256.
2021-02-08 18:01:23 +01:00
Linus Groh
79bab28f5e LibWeb: Implement Element.getElementsBy{Tag,Class}Name()
Just like the Document variants, but using the given Element as
for_each_in_subtree_of_type() root.
2021-02-08 17:59:04 +01:00
Linus Groh
2a38f008bf LibWeb: Make getElementsByClassName() case-insensitive in quirks mode
From https://dom.spec.whatwg.org/#concept-getelementsbyclassname:

    The comparisons for the classes must be done in an ASCII case-
    insensitive manner if root’s node document’s mode is "quirks", and
    in an identical to manner otherwise.
2021-02-08 17:59:04 +01:00
Linus Groh
5a9094a70a LibWeb: Make getElementsByTagName() case-insensitive for HTML elements
From https://dom.spec.whatwg.org/#concept-getelementsbytagname:

    2. Otherwise, if root’s node document is an HTML document, return a
       HTMLCollection rooted at root, whose filter matches the following
       descendant elements:

       * Whose namespace is the HTML namespace and whose qualified name
         is qualifiedName, in ASCII lowercase.

       * Whose namespace is not the HTML namespace and whose qualified
         name is qualifiedName.
2021-02-08 17:59:04 +01:00
Andreas Kling
33c7017f6e LibGUI: Add missing "final" in TextEditor 2021-02-07 19:32:40 +01:00
Andreas Kling
50308f6fda Shell: Move Shell syntax highlighter LibShell 2021-02-07 17:07:33 +01:00
Andreas Kling
ddbf20ecf6 LibSyntax+LibGUI+LibJS: Move JS syntax highlighter to LibJS
This is a little bit messy but the basic idea is:

Syntax::Highlighter now has a Syntax::HighlighterClient to talk to the
outside world. It mostly communicates in LibGUI primitives that are
available in headers, so inlineable.

GUI::TextEditor inherits from Syntax::HighlighterClient.

This let us to move GUI::JSSyntaxHighlighter to JS::SyntaxHighlighter
and remove LibGUI's dependency on LibJS.
2021-02-07 16:56:02 +01:00
Andreas Kling
22baa5e64f LibGfx: Make Palette::color(ColorRole) inline 2021-02-07 16:53:39 +01:00
Andreas Kling
767ff06f56 LibGfx: Make Color(NamedColor) inline and constexpr 2021-02-07 16:51:17 +01:00
Andreas Kling
43c7d7d285 LibSyntax: Move GUI::Highlighter to Syntax::Highlighter in LibSyntax
This is a move towards dropping more LibGUI dependencies.
2021-02-07 15:15:10 +01:00
Andreas Kling
ff2438e0ce LibGUI+LibCpp: Move C++ syntax highlighter to LibCpp
This makes LibGUI not depend on LibCpp.
2021-02-07 14:40:36 +01:00
AnotherTest
6985b4008a LibLine: Place the search editor prompt at the right line after ^L
...as the search editor prompt has to always stay after the main prompt preview.
2021-02-07 13:12:56 +01:00
AnotherTest
3a231c00aa LibLine: Close the search editor when it's interrupted
Fixes #5233.
2021-02-07 13:12:56 +01:00
Andreas Kling
0eac44af49 LibWeb: Don't assert on <colgroup> & friends
Let's just construct a placeholder BlockBox layout node for now.

Fixes #5081.
2021-02-07 11:47:33 +01:00
Andreas Kling
796c31a52b LibWeb: Reorganize Element::create_layout_node() into a switch
This allows us to see which CSS::Display types are not yet handled.
2021-02-07 11:40:42 +01:00
Andreas Kling
e6712fcd82 LibWeb: Use any_of() for DOM::Element::has_class() 2021-02-07 11:35:26 +01:00
Andreas Kling
330c3fcb59 LibWeb: Use move semantics for QualifiedName more often 2021-02-07 11:20:15 +01:00
Andreas Kling
10420dee7e LibGfx: Fix global-buffer-overflow in interlaced GIF decode
Regressed with 57e10eadac and immediately
caught by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30507
2021-02-07 11:18:55 +01:00
Andreas Kling
0c66e53544 LibWeb: Honor font sizes specified by CSS
Instead of trying to coerce them into some font size we think we might
have, let's just honor the request and do our best to find a font.
2021-02-07 10:57:07 +01:00
Andreas Kling
3620a6e054 LibJS: Function must mark its home object 2021-02-07 10:57:07 +01:00
Andreas Kling
57e10eadac LibGfx: Don't reject valid GIF animations with interlaced frames
We were returning early from the deinterlacing loop after the very last
pass, but we should just let the outer loop finish and return instead.

This makes the Netscape animation on https://timmorgan.dev work. :^)
2021-02-07 01:21:42 +01:00
Andreas Kling
ce1c8e0bde LibWeb: Anonymous table cells should have colspan=1
Otherwise the column widths calculation algorithm will assert.

Fixes #5078.
2021-02-06 23:27:03 +01:00
Sergey Bugaev
d8967e4dff LookupServer+LibC: Pass IP addresses in binary
Now that we no longer depend on the textual IPC format, we can pass IP addresses
in the format most code actually has and needs it: in binary. The only places we
actually have to deal with textual address representation is:

* When reading /etc/hosts, we have to parse textual addresses & convert them to
  binary;
* When doing reverse lookups, we have to form a pseudo-hostname of the form
  x.x.x.x.in-addr.arpa.

So we do the conversion in those two cases.

This also increases uniformity between how we handle A (IPv4 address) and other
resource record types. Namely, we now store the raw binary data as received from
a DNS server.
2021-02-06 17:52:47 +01:00
Sergey Bugaev
547130584c LookupServer: Switch to LibIPC :^)
The ad-hoc IPC we were doing with LookupServer was kinda gross. With this,
LookupServer is a regular IPC server. In the future, we want to add more APIs
for LookupServer to talk to its clients (such as DHCPClient telling LookupServer
about the DNS server discovered via DHCP, and DNS-SD client browsing for
services), which calls for a more expressive IPC format; this is what LibIPC is
perfect for.

While the LookupServer side is using the regular LibIPC mechanics and patterns,
the LibC side has to hand-roll LibIPC format serialization without actually
using LibIPC. We might be able to get rid of this in the future, but for now it
has to be like that. The good news is the format is not that bad at all.
2021-02-06 16:12:18 +01:00
Andreas Kling
7df3b95126 LibJS: GlobalObject must mark builtin prototypes
Failing to mark them leads to use-after-free since the GlobalObject
cached prototypes are used for new NumberObject, StringObject, etc.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30319
2021-02-05 14:53:16 +01:00
Andreas Kling
0269578d3e LibM: Implement nextafter() and nexttoward()
Patch from Anonymous.
2021-02-05 12:27:23 +01:00
Andreas Kling
e87eac9273 Userland: Add LibSystem and funnel all syscalls through it
This achieves two things:

- Programs can now intentionally perform arbitrary syscalls by calling
  syscall(). This allows us to work on things like syscall fuzzing.

- It restricts the ability of userspace to make syscalls to a single
  4KB page of code. In order to call the kernel directly, an attacker
  must now locate this page and call through it.
2021-02-05 12:23:39 +01:00
Andreas Kling
4df3a34bc2 LibELF: Only set up PLT trampoline for objects with a PLT 2021-02-05 12:10:45 +01:00
Andreas Kling
9d471ea923 LibM: Build and install the LibM test
This test seems to be full of wrong, but at least now we build it and
place it in /usr/Tests/LibM/ so that we can fix it.
2021-02-05 09:50:08 +01:00
Andreas Kling
16a0e7a66d LibJS: Improve correctness of rounding and bitwise operations
Patch from Anonymous
2021-02-05 09:38:45 +01:00
Andreas Kling
6622ad8895 LibM: Improve accuracy of rounding related functions
Patch from Anonymous.
2021-02-05 09:38:45 +01:00
Andreas Kling
acabc37c24 SymbolServer+LibSymbolClient: Just do one symbol per IPC message
I originally wanted to batch the symbolication requests but that just
makes the client logic significantly more complicated with no real
benefit other than architectural feelgood points.
2021-02-04 23:35:10 +01:00
Andreas Kling
b7d16e3496 LibSymbolClient+bt: Move bt logic to SymbolClient::symbolicate_thread()
Since this is useful in many places, let's have a common implementation
of walking the stack of a given thread via /proc and symbolicating each
of the frames.
2021-02-04 23:20:39 +01:00
Andreas Kling
5249aa2ba5 LibSymbolClient: Add helper library for interfacing with SymbolServer 2021-02-04 23:20:39 +01:00
Andreas Kling
91db36064f LibJS: Fix obviously wrong \uXXXX serialization in JSONObject 2021-02-04 00:09:04 +01:00
Andreas Kling
349cf6ad67 LibELF: Randomize the VM reservation (so we don't break ASLR) 2021-02-04 00:04:26 +01:00
Andreas Kling
3a3270eb68 LibELF: Make a dummy VM reservation before mapping dynamic objects
Using the text segment for the VM reservation ran into trouble when
there was a discrepancy between the p_filesz and p_memsz.

Simplify this mechanism and avoid trouble by making the reservation
as a MAP_PRIVATE | MAP_NORESERVE throwaway mapping instead.

Fixes #5225.
2021-02-03 23:42:18 +01:00
Andreas Kling
c9cd5ff6bb LibELF: Remove dynamic loader syscall exception for libkeyboard.so
LibKeyboard no longer needs to make syscalls so remove the exception
we were making for it. :^)
2021-02-03 23:15:53 +01:00
Andreas Kling
d32ed28df4 LibC+LibKeyboard: Move getkeymap()+setkeymap() syscall wrappers to LibC 2021-02-03 23:15:13 +01:00
Andreas Kling
a59b1825ce LibWeb: Basic implementation of global event handlers :^)
Document and HTMLElement now inherit from HTML::GlobalEventHandlers
which allows them to support "onfoo" event handler attributes.

These are assignable both via IDL attributes and content attributes.

Event listeners constructed this way get a special "attribute" flag
on them so we know which one to replace if you reassign them.
This also allows them to coexist with EventTarget.addEventListener().

This is all a bit sloppy, but it works decently for a first cut.
The Window object should also inherit GlobalEventHandlers, but since
we don't generate it from IDL, I haven't taken that step here.

Also this would be a lot nicer if we supported IDL mixins.
2021-02-03 23:03:05 +01:00
Andreas Kling
b43db4cc50 LibWeb: Add enumerator macro for all the "global event handlers" 2021-02-03 23:03:05 +01:00
Andreas Kling
14a6ec6fc9 LibWeb: Add a whole bunch of onfooevent names to HTML::AttributeNames 2021-02-03 23:03:05 +01:00
Andreas Kling
9c77980965 Everywhere: Remove some bitrotted "#if 0" blocks 2021-02-03 11:17:47 +01:00
Andreas Kling
342b787d1c LibWeb: Move main thread JavaScript VM to its own file
Instead of being a weird little global function in DOM/Document.cpp,
you can now get the main thread JS VM via Bindings::main_thread_vm().
2021-02-03 10:45:39 +01:00
Zac
cc2f35badd TextEditor: Implement word wrapping
Add a new wrapping mode to the TextEditor that will wrap lines at the
spaces between words.

Replace the previous menubar checkbox 'Wrapping Mode' in HackStudio and
the TextEditor with an exclusive submenu which allows switching between
'No wrapping', 'Wrap anywhere' and 'Wrap at words'. 'Wrap anywhere' (the
new 'Wrap lines') is still the default mode.

Setting the wrapping mode in the constructors of the TextEditorWidget
and HackStudio has been removed, it is now set when constructing the
menubar actions.
2021-02-03 10:33:23 +01:00
Andreas Kling
db1c6cf9cf LibC+LibELF: Run clang-format 2021-02-03 10:21:04 +01:00
Andreas Kling
603d36c599 LibELF: Make syscall region exceptions for UE and libkeyboard.so
These two are currently making some syscalls so we'll have to make
exceptions for them until we can clean them up.
2021-02-02 20:13:44 +01:00
Andreas Kling
de149dc7fa LibX86: Don't assert just because insn has no immediate bytes
It's perfectly fine to not have immediate bytes. Many insns don't :^)
2021-02-02 20:13:44 +01:00
Andreas Kling
df7ddfb803 LibELF: Mark libc.so and libpthread.so as syscall regions
Also, before calling the main program entry function, inform the kernel
that no more syscall regions can be registered.

This effectively bans syscalls from everywhere except LibC and
LibPthread. Pretty neat! :^)
2021-02-02 20:13:44 +01:00