Commit graph

402 commits

Author SHA1 Message Date
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
Andreas Kling
d57b4128a1 LibCore: Use serenity_readlink() instead of making syscalls directly 2021-02-02 20:13:44 +01:00
Andreas Kling
1658df9b6e LibC: Add LibC wrapper for sys$readlink()
To avoid having to make direct syscalls in LibCore, let's add a wrapper
for the kernel's readlink syscall in LibC.
2021-02-02 20:13:44 +01:00
Andreas Kling
775ae27a55 Revert "StatusBar: Allow GML files to set the number of labels to create"
This reverts commit e11ec20650.

Broke FileManager, Browser, etc.
2021-02-02 19:02:01 +01:00
Andreas Kling
31e04907b4 Revert "TextEditor: Add vim status indicators to the statusbar"
This reverts commit bd6d0d2295.
2021-02-02 19:01:54 +01:00
Linus Groh
50957ec78e LibJS: Fix variable name coding style int{Part => _part}
...and rename intpart_end to int_part_end for consistency.
2021-02-02 16:52:55 +01:00
Zac
bd6d0d2295 TextEditor: Add vim status indicators to the statusbar
When using the VimEditingEngine in the TextEditor, vim's mode and the
previous key are shown in the editor's statusbar.
2021-02-02 16:08:20 +01:00
Zac
e11ec20650 StatusBar: Allow GML files to set the number of labels to create 2021-02-02 16:08:20 +01:00
Andreas Kling
1d394b8a76 LibELF: Close dynamic objects after mapping and linking them
Oops, we were leaving the file descriptors open.
2021-02-01 20:10:03 +01:00
Liav A
c6fe1de30e LibC: Expose various option variables for later usage
These variables are used by the dmidecode utility to parse the
commandline arguments that were specified by the user.
2021-02-01 17:13:23 +01:00
Andreas Kling
1ce03f4f34 LibIPC: Stop sending client ID to clients
The client ID is not useful to normal clients anymore, so stop telling
everyone what their ID is.
2021-02-01 11:32:00 +01:00
Andreas Kling
a5bbe3280d LibGUI+WindowServer: Don't use a WM IPC to initiate own window resize
The WM_* IPC messages are intended for "outsider" window management,
not for a client's own windows. Make a separate StartWindowResize
message for this.

This was the only reason that every IPC client had to know its server
side client ID.
2021-02-01 11:23:54 +01:00
Linus Groh
c41d340983 LibJS: Use VM::names for Object::invoke() function names 2021-02-01 10:34:45 +01:00
Ben Wiederhake
272df54a3e Kernel+LibKeyboard: Define the default keymap only in one place
Because it was 'static const' and also shared with userland programs,
the default keymap was defined in multiple places. This commit should
save several kilobytes! :^)
2021-02-01 09:54:32 +01:00
Ben Wiederhake
0e3408d4d6 LibKeyboard: Don't assert on failure 2021-02-01 09:54:32 +01:00
Ben Wiederhake
dd4e670f72 LibKeyboard+keymap: Support querying the keymap via commandline 2021-02-01 09:54:32 +01:00
Ben Wiederhake
a2c21a55e1 Kernel+LibKeyboard: Enable querying the current keymap 2021-02-01 09:54:32 +01:00
Ben Wiederhake
aa3d915260 LibTextCodec: Avoid duplicate definition of standard encodings 2021-02-01 09:54:32 +01:00
Thomas Mangin
34508c0b01 LibX86: sanity check for Instruction read size
During "Emulator hacking: Let's make the userspace emulator go faster!",
the switch implented in read() was inlined (toward the end of the video).

This patch restore the assert check for any read other than 8, 16 or 32
bits was lost during the code conversion.
2021-01-31 19:06:24 +01:00
AnotherTest
3b9ead985c LibLine: Only print ascii characters in caret form
ctype's `iscntrl` truncates its input, making some codepoints appear as
control characters. Avoid this by checking whether the character is in
ascii to begin with.
2021-01-31 19:06:02 +01:00
Linus Groh
521a38d9c5 LibWeb: Use URL::to_string_encoded() for the crash error page URL's href
Just wrapping to_string() in urlencode() will break the link as too many
characters are encoded. Also wrap in escape_html_entities() as well -
most relevant chars are already URL-encoded, but this will change '&' to
'&', for example.
2021-01-31 19:05:55 +01:00
Andreas Kling
fc4eae87f8 LibC: Don't honor LIBC_* malloc debugging flags in AT_SECURE context
Just ignore all these environment flags if the AT_SECURE flag is set in
the program's auxiliary vector.

This prevents a user from tricking set-uid programs into dumping debug
information via environment flags.
2021-01-31 14:37:21 +01:00
Andreas Kling
e313323317 LibELF: Split the DynamicLoader's loading mechanism into two steps
load_from_image() becomes map() and link(). This allows us to map
an object before mapping its dependencies.

This solves an issue where fixed-position executables (like GCC)
would clash with the ASLR placement of their own shared libraries.
2021-01-31 11:46:00 +01:00
Andreas Kling
36525c0572 LibELF: Assert on multiple calls to DynamicLoader::load_from_image()
It would be a mistake to recreate the cached DynamicObject.
2021-01-31 11:32:16 +01:00
Andreas Kling
2b862e4569 LibELF: Don't validate ELF twice in DynamicLoader
Validation was happening in two steps, some in the constructor, and then
some later on, in load_from_image().

This made no sense so just move all the validation to the constructor.
2021-01-31 11:29:23 +01:00
Andreas Kling
68576bcf1b LibELF: Call mmap() before constructing the DynamicLoader object
Refactor DynamicLoader construction with a try_create() helper so that
we can call mmap() before making a loader. This way the loader doesn't
need to have an "mmap failed" state.

This patch also takes care of determining the ELF file size in
try_create() instead of expecting callers to provide it.
2021-01-31 11:06:00 +01:00
Andreas Kling
d71bfb9614 LibC: Fix bad error check after open() in dlopen() 2021-01-31 11:06:00 +01:00
Andreas Kling
1b5be4a342 LibIPC: Stop exchanging client/server PIDs in greeting handshake
The PIDs were used for sharing shbufs between processes, but now that
we have migrated to file descriptor passing, we no longer need to know
the PID of the other side.
2021-01-31 09:29:27 +01:00
Andreas Kling
df2a4adcd2 Browser+LibWeb+WebContent: Make the "Debug" menu work in multi-process
This patch adds an IPC call for debugging requests. It's stringly typed
and very simple, and allows us to easily implement all the features in
the Browser's Debug menu.
2021-01-31 09:07:46 +01:00
Andreas Kling
74c8490acd LibWeb: Don't try to create GUI::TextBox inside multi-process web views
This is a workaround until we can implement a proper <input type=text>
in terms of LibWeb primitives.

This makes google.com not crash in multi-process mode (but there is no
search box.)
2021-01-30 23:16:41 +01:00
Peter Elliott
c0e88b9710 Kernel: Add FIBMAP ioctl to Ext2FileSystem
FIBMAP is a linux ioctl that gives the location on disk of a specific
block of a file
2021-01-30 22:54:51 +01:00
Linus Groh
e8aae033f1 LibWeb: URL-encode/escape variables used in OOPWV's crash error page
This fixes arbitrary HTML injections via the URL on OOPWV's crash error
page - probably not a security issue, but annoying nonetheless.
2021-01-30 22:49:34 +01:00
Andreas Kling
f3e85e43c7 LibWeb: Handle WebContent process crashes gracefully :^)
The OOPWV will now detect WebContent process crashes/disconnections and
simply create a new WebContent process in its place. We also generate a
little error page with a link to the crashing URL so you can reload and
try again.

This a huge step forward for OOPWV since it now has a feature that IPWV
can never replicate. :^)
2021-01-30 18:27:39 +01:00
AnotherTest
322936115e LibProtocol: Bump download stream buffer to PAGE_SIZE
I think this should scale based on the network speed (or download
rate?), but for the time being, 4K seems to be good-enough.
2021-01-30 14:12:14 +01:00
Andreas Kling
d9c5fdf5d5 LibGUI: Handle Window::hide() during Application teardown better
If a window is being torn down during app shutdown, the global
application pointer may be nulled out already. So let's handle that
case gracefully in Window::hide().
2021-01-30 14:03:53 +01:00
Andreas Kling
5bf9999652 LibELF: Add a bunch of overflow checks in ELF validation 2021-01-30 13:54:24 +01:00
Andreas Kling
9b0ca75f84 LibWeb: Add Frame::ViewportClient and use it for Layout::ImageBox
Image boxes want to know whether they are inside the visible viewport.
This is used to pause/resume animations, and to update the purgeable
memory volatility state.

Previously we would traverse the entire layout tree on every resize,
calling a helper on each ImageBox. Make those boxes register with the
frame they are interested in instead, saving us all that traversal.

This also makes it easier for other parts of the code to learn about
viewport changes in the future. :^)
2021-01-30 12:29:11 +01:00
Andreas Kling
553361d83f LibC: Protect the atexit() handler list when not writing to it
Remap the list of atexit handlers as read-only while we're not actively
writing to it. This prevents an attacker from using a memory write
primitive to gain code execution via the atexit list.

This is based on a technique used in OpenBSD. :^)
2021-01-30 10:41:36 +01:00
Andreas Kling
5b37c0a71a LibC: Convert remaining String::format() to formatted()/number() 2021-01-30 09:29:51 +01:00
Ben Wiederhake
ec91f8ad1d LibELF: Avoid quadratic memory usage weakness
Section names are referred to by offset and length. We do not check
(and probably should not check) whether these names overlap in any way.
This opened the door to many sections (in this example: about 2700)
forcing ELF::Image::m_sections to contain endless copies of the same
huge string (in this case: 882K).

Fix this by loading only the first PAGE_SIZE bytes of each name.
Since section names are only relevant for relocations and debug
information and most section names are hard-coded (and far below 4096
bytes) anyway, this should be no restriction at all for 'normal'
executables.

Found by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29187
2021-01-30 09:25:02 +01:00
Ben Wiederhake
4332dfb964 LibGfx: Fix dynamic bitmasks in BMPs
I overlooked a corner case where we might call the built-in ctz() on zero.

Furthermore, the calculation of the shift was wrong and the results were often
unusable.

Both issue were caused by a forgotten 36daeee34f.
This time I made sure to look at bmpsuite_files first, and now they look good.

Found by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28985
2021-01-30 09:23:18 +01:00
Jorropo
8f8bbd1bcd
DynamicLoader: load_program_headers use variables to store regions (#5173)
Previously regions were stored in a vector and then a pointer to
regions in this vector were taken and stored. The problem is the vector
were still appended after pointers were taken, if enough regions were
present the vector would grow so large that it needed a resize, this
cause his memory to moved and now the previous pointers are now
pointing to old memory we just freed.

Fixes #5160
2021-01-30 09:21:54 +01:00
Andreas Kling
7449c1b27f ImageDecoder+LibImageDecoder+LibWeb: Support animations in ImageDecoder
The ImageDecoder service now returns a list of image frames, each with
a duration value.

The code for in-process image decoding is removed from LibWeb, an all
image decode requests are sent out-of-process to ImageDecoder. :^)

This won't scale super well to very long and/or large animations, but
we can work on improving that separately. The main goal here is simply
to stop doing any image decoding inside LibWeb.

Fixes #5165.
2021-01-29 22:38:22 +01:00