Commit graph

21706 commits

Author SHA1 Message Date
Linus Groh
6c256bb400 LibJS: Add @@toStringTag to Reflect 2021-06-08 19:13:14 +01:00
Linus Groh
b377777208 LibJS: Add @@toStringTag to Promise.prototype 2021-06-08 19:13:14 +01:00
Linus Groh
ed64a69fb2 LibJS: Replace two instances of 'global_object.vm()' with just 'vm' 2021-06-08 19:13:14 +01:00
Gunnar Beutner
75a12bc2b7 LibJS: Generate bytecode for template literals 2021-06-08 19:47:32 +02:00
Sam Atkins
0b2bf3d73a gron: Handle invalid input gracefully
Print an error and return 1, instead of asserting.
2021-06-08 19:15:12 +02:00
Sam Atkins
d09fb8f599 gron: Make gron read from stdin if no file is provided 2021-06-08 19:15:12 +02:00
Ali Mohammad Pur
7ac196974d Everywhere: Replace Vector<T*> with nonnull entries with Vector<T&> 2021-06-08 19:14:24 +02:00
Ali Mohammad Pur
3d94b5051d AK: Make Vector capable of holding reference types
This commit makes it possible to instantiate `Vector<T&>` and use it
to store references to `T` in a vector.
All non-pointer observers are made to return the reference, and the
pointer observers simply yield the underlying pointer.
Note that the 'find_*' methods act on the values and not the pointers
that are stored in the vector.
This commit also makes errors in various vector methods much more
readable by directly using requires-clauses on them.
And finally, it should be noted that Vector cannot hold temporaries :^)
2021-06-08 19:14:24 +02:00
Ali Mohammad Pur
48195b7c30 AK: Switch to east const in Vector.h
Let's get this out of the way before touching the file.
2021-06-08 19:14:24 +02:00
Ali Mohammad Pur
b7b0b199a8 AK: Reorder Vector methods to place similar methods next to each other
The methods of this class were all over the place, this commit reorders
them to place them in a more logical order:
- Constructors/Destructor
- Observers
- Comparisons and const existence checks
- Mutators: insert
- Mutators: append
- Mutators: prepend
- Mutators: assignment
- Mutators: remove
- OOM-safe mutators: insert
- OOM-safe mutators: append
- OOM-safe mutators: prepend
- OOM-safe size management
- Size management
- Iterators
2021-06-08 19:14:24 +02:00
Ali Mohammad Pur
c3fa13fa73 AK: Rename Vector::{value_type => ValueType} 2021-06-08 19:14:24 +02:00
Timothy Flynn
c7cd81bce8 LibSQL: Limit the number of nested subqueries
SQLite hasn't documented a limit on https://www.sqlite.org/limits.html
for the maximum number of nested subqueries. However, its parser is
generated with Yacc and has an internal limit of 100 for general nested
statements.

Fixes https://crbug.com/oss-fuzz/35022.
2021-06-08 19:08:13 +02:00
Timothy Flynn
4e974e6d60 LibSQL: Rename expression tree depth limit test case
Meant to rename this before committing the test - 'stack_limit' isn't a
great name when there's multiple test cases for various stack overflows.
2021-06-08 19:08:13 +02:00
Max Wipfli
3b04420490 AK: Don't create Utf8View from temporary String in URLParser
This fixes a bug where a Utf8View was created with data from a temporary
string, which was immediately deleted. This lead to a use-after-free
issue. This also changes most occurences for StringBuilder::to_string in
URLParser to use ::string_view(), as the value is passed as StringView
const& most of the time anyways.

This fixes oss-fuzz issue 34973.
2021-06-08 19:08:02 +02:00
Max Wipfli
3c7e775a9a AK: Utf8CodePointIterator: Don't output full string to debug output
When a code point is invalid, the full string was outputted to the debug
output. For large strings, this can make the system quite slow.
Furthermore, one of the cases incorrectly assumed the data to be null
terminated. This patch modifies the debug statements not to print the
full string.

This fixes oss-fuzz issue 35050.
2021-06-08 19:08:02 +02:00
Jelle Raaijmakers
efae7b7748 Ports/ScummVM: Add freetype, libiconv, libjpeg and libpng to build deps 2021-06-08 17:29:57 +02:00
Jelle Raaijmakers
4bf9f334d5 Ports/ScummVM: Use SERENITY_INSTALL_ROOT instead of _BUILD_DIR 2021-06-08 17:29:57 +02:00
Gunnar Beutner
ac9dbcda97 LibM: Implement nearbyint, nearbyintl and nearbyintf
These are used by the ultima engine for scummvm.
2021-06-08 17:29:57 +02:00
Gunnar Beutner
d2662df57c LibC+AK: Remove our custom macros from <assert.h>
Other software might not expect these to be defined and behave
differently if they _are_ defined, e.g. scummvm which checks if
the TODO macro is defined and fails to build if it is.
2021-06-08 17:29:57 +02:00
Leon Albrecht
c6ce7c9326
LibJS: Seal Bytecode Blocks and munmap them (#7919) 2021-06-08 17:21:48 +02:00
Idan Horowitz
064ed8279e LibJS: Support deleting local variables with operator delete
To make this cleaner i also moved the logic into Reference::delete_.
2021-06-08 15:31:46 +01:00
Idan Horowitz
af58779def LibJS: Return undefined from a with statement if no value was generated
Co-authored-by: Linus Groh <mail@linusgroh.de>
2021-06-08 15:31:46 +01:00
Idan Horowitz
98897ff676 LibJS: Return the last value from a with statement 2021-06-08 15:31:46 +01:00
Max Wipfli
73084835da Base: Clarify and extend unveil(2) man page 2021-06-08 12:15:04 +02:00
Max Wipfli
573664758a Kernel: Properly reset m_unveiled_paths on execve()
When a process executes another program, its unveil state is reset. For
this, we not only need to clear all nodes from m_unveiled_paths, but
also reset the metadata of m_unveiled_paths (the root node) itself.

This fixes the following bug:
1) A process unveils "/", then executes another program.
2) That other program also unveils some path.
3) "/" is now unveiled for the new program.
2021-06-08 12:15:04 +02:00
Max Wipfli
c1de46aaaf Kernel: Don't assume there are no nodes if m_unveiled_paths.is_empty()
If m_unveiled_paths.is_empty(), the root node (which is m_unveiled_paths
itself) is the matching veil. This means we should not return nullptr in
this case, but just use the code path for the general case.

This fixes a bug where calling e.g. unveil("/", "r") would refuse you
access to anything, because find_matching_unveiled_path would wrongly
return nullptr.

Since find_matching_unveiled_path can no longer return nullptr, we can
now just return a reference instead.
2021-06-08 12:15:04 +02:00
Max Wipfli
8930db0900 Kernel: Change unveil state to dropped even when node already exists
This also changes the UnveilState to Dropped when the path unveil() is
called for already has a node.

This fixes a bug where unveiling "/" would previously keep the
UnveilState as None, which meant that everything was still accessible
until unveil() was called with any non-root path (or nullptr).
2021-06-08 12:15:04 +02:00
Max Wipfli
2fcebfd6a8 Kernel: Update intermediate nodes when changing unveil permissions
When changing the unveil permissions of a preexisting node, we need to
make sure that any intermediate nodes that were created before and
should inherit permissions from the updated node are updated properly.

This fixes the following bug:
unveil("/home/anon/Documents", "r");
unveil("/home", "r");
Now there was a intermediate node for "/home/anon" which still had no
permission, even though it should have inherited the permissions from
"/home".
2021-06-08 12:15:04 +02:00
Max Wipfli
1e8006ebb8 AK: Add children() accessor to Trie 2021-06-08 12:15:04 +02:00
Max Wipfli
e8a317023d Kernel: Allow unveiling subfolders regardless of parent's permissions
This fixes a bug where unveiling a subdirectory of an already unveiled
path would sometimes be allowed and sometimes not (depending on what
other unveil calls have been made).

Now, it is always allowed to unveil a subdirectory of an already
unveiled directory, even if it has higher permissions.

This removes the need for the permissions_inherited_from_root flag in
UnveilMetadata, so it has been removed.
2021-06-08 12:15:04 +02:00
Max Wipfli
9d41dd2ed0 Kernel: Use LexicalPath to avoid two consecutive slashes in unveil path
This patch fixes a bug in the unveil syscall where an UnveilNode's path
would start with two slashes if it's parent node was "/".
2021-06-08 12:15:04 +02:00
Linus Groh
68ce69db88 LibJS: Add for loop bytecode generation 2021-06-08 11:59:32 +02:00
Gunnar Beutner
50ece3dd1b LibJS: Implement bytecode generation for BigInts 2021-06-08 10:57:28 +01:00
Gunnar Beutner
0975e08285 LibJS: Make if yield undefined for the else branch if it is missing 2021-06-08 11:38:48 +02:00
Gunnar Beutner
d9989fd259 LibJS: Remove redundant jump for IfStatements 2021-06-08 11:38:48 +02:00
Gunnar Beutner
ef83872f62 LibJS: Make JumpIf{True,False,Nullish} inherit from Jump
This saves a few lines in LogicalExpression::generate_bytecode.
2021-06-08 11:38:48 +02:00
Jelle Raaijmakers
afbbcde150 Utilities: Make xargs stop parsing options on first non-option 2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
3c7ddf383a Utilities: Make watch stop parsing options on first non-option 2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
fb6d141601 Utilities: Make strace stop parsing options on first non-option 2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
00fc0a6cf0 Shell: Make time stop parsing options on first non-option 2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
a32fe8df33 UserspaceEmulator: Stop parsing options on first non-option 2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
001c81b1be Userland: Let env parse options up to first non-option 2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
d7126fbbc2 LibCore/ArgsParser: Learn how to stop on first non-option
We need this for utilities like `env`, that do not gain anything by
parsing the options passed to the command they are supposed to
execute.
2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
0b0bce78f6 LibCore/ArgsParser: Add test suite
This adds a very basic test suite for ArgsParser that we can use to set
a baseline of functionality that we want to make sure keeps working.
2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
d6a3f1fcd7 Kernel: Simplify execve shebang argument handling 2021-06-08 11:30:58 +02:00
Jelle Raaijmakers
250f8eccf3 LibCore: Support fine-grained failure behavior for ArgsParser 2021-06-08 11:30:58 +02:00
Luke
1dc31842cb LibJS: Add sequence expression bytecode generation 2021-06-08 11:20:10 +02:00
Max Wipfli
cac94b1c16 Kernel: Implement InodeFile::stat() and simplify FileDescription::stat() 2021-06-08 11:12:31 +02:00
Andreas Kling
675b0aee24 Websites: Some updates for the serenityos.org front page
- Add link to the Discord server
- Remove reference to Freenode IRC channel since it's no longer used
- Add sponsorship links for Linus :^)
2021-06-08 10:56:52 +02:00
Luke
de3ee701ce LibJS: Add conditional expression bytecode generation
Or, by its more common name, the ternary operator :^)
2021-06-08 09:53:56 +01:00