summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-01-11DoublyLinkedList: Implement `find` in terms of `AK::find`Lenny Maiorani
Problem: - The implementation of `find` is coupled to the implementation of `DoublyLinkedList`. - `append` and `prepend` are implemented multiple times so that r-value references can be moved from into the new node. This is probably not called very often because a pr-value or x-value needs to be used here. Solution: - Decouple the implementation of `find` from the class by using a generic `find` algorithm. - Make `append` and `prepend` be function templates so that they can have binding references which can be forwarded.
2021-01-11Vector: Implement `find`, `find_if`, `find_first_matching` in terms of ↵Lenny Maiorani
`AK::find*` Problem: - The implementation of `find` is coupled to the implementation of `Vector`. - `Vector::find` takes the predicate by value which might be expensive. Solution: - Decouple the implementation of `find` from `Vector` by using a generic `find` algorithm. - Change the name of `find` with a predicate to `find_if` so that a binding reference can be used and the predicate can be forwarded to avoid copies. - Change all the `find(pred)` call sites to use `find_if`.
2021-01-11AK: Find a value in any container offering iteratorsLenny Maiorani
Problem: - `find` is implemented inside of each container. This coupling requires that each container needs to individually provide `find`. Solution: - Decouple the `find` functionality from the container. This allows provides a `find` algorithm which can work with all containers. Containers can still provide their own `find` in the case where it can be optimized. - This also allows for searching sub-ranges of a container rather than the entire container as some of the container-specific member functions enforced. Note: - @davidstone's talk from 2015 C++Now conference entitled "Functions Want to be Free" encourages this style: (https://www.youtube.com/watch?v=_lVlC0xzXDc), but it does come at the cost of composability. - A logical follow-on to this is to provide a mechanism to use a short-hand function which automatically searches the entire container. This could automatically use the container-provided version if available so that functions which provide their own optimized version get the benefit.
2021-01-11LibGfx: Fail PBM decode if there isn't enough color data in imageAndreas Kling
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29417
2021-01-11CrashDaemon: Use pledgeAndreas Kling
2021-01-11Kernel: Don't dump perfcore for non-dumpable processesAndreas Kling
Fixes #4904
2021-01-11UserspaceEmulator: Implement the ftruncate and umask syscallsAndreas Kling
It's now possible to copy files with FileManager running in UE. :^)
2021-01-11Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11LibGUI: Update TextEditor after triple-click to select (#4897)campital
Previously, it was "relying" on the cursor blink timer to update the visual selection. This caused some delay after the whole line was selected by triple-clicking specifically the last word in a line. Now, the widget is updated after triple-clicking.
2021-01-11Kernel: Fix perfcore filename generation build errorAndreas Kling
2021-01-11Kernel+Profiler: Make profiling per-process and without core dumpsAndreas Kling
This patch merges the profiling functionality in the kernel with the performance events mechanism. A profiler sample is now just another perf event, rather than a dedicated thing. Since perf events were already per-process, this now makes profiling per-process as well. Processes with perf events would already write out a perfcore.PID file to the current directory on death, but since we may want to profile a process and then let it continue running, recorded perf events can now be accessed at any time via /proc/PID/perf_events. This patch also adds information about process memory regions to the perfcore JSON format. This removes the need to supply a core dump to the Profiler app for symbolication, and so the "profiler coredump" mechanism is removed entirely. There's still a hard limit of 4MB worth of perf events per process, so this is by no means a perfect final design, but it's a nice step forward for both simplicity and stability. Fixes #4848 Fixes #4849
2021-01-10Kernel: Avoid collision between dynamic loader and main programItamar
When loading non position-independent programs, we now take care not to load the dynamic loader at an address that collides with the location the main program wants to load at. Fixes #4847.
2021-01-10Kernel: Plumb the elf header of the main program down to Process::loadItamar
This will enable us to take the desired load address of non-position independent programs into account when randomizing the load address of the dynamic loader.
2021-01-10LibJS: Replace all uses of to_size_t() and remove it :^)Linus Groh
Yay for more spec compliance! This is pretty easy as everything using to_size_t() should just be using one of the other abstract operations we already have implemented. This allows us to get rid of get_length() in ArrayPrototype, which is basically a slightly incorrect implementation of length_of_array_like(), and then finally remove to_size_t()! Also fixes a couple of "argument is undefined" vs "argument isn't given" issues along the way.
2021-01-10LibJS: Make length_of_array_like() take an Object rather than ValueLinus Groh
The pseudo-code from the spec says "Assert: Type(obj) is Object.", so we can just enforce this at compile time rather than taking it literally and doing "ASSERT(value.is_object())". Also fix an issue where the absence of a "length" property on the object would cause a crash (to_number() on empty value).
2021-01-10Kernel: Defer handling of key press events in VirtualConsoleAndrew Kaster
Trying to pass these onto the Terminal while handling an IRQ is a recipe for disaster. Use Processor::deferred_call_queue to create an ad-hoc "second half" of the interrupt handler. Fixes #4889
2021-01-10SystemServer: Allow /dev/fb0 to not exist, for text mode support.Andrew Kaster
2021-01-10LibJS: Implement String.prototype.splitMarcin Gasperowicz
This adds a String.prototype.split implementation modelled after ECMA262 specification. Additionally, `Value::to_u32` was added as an implementation of the standard `ToUint32` abstract operation. There is a tiny kludge for when the separator is an empty string. Basic tests and visiting google.com prove that this is working.
2021-01-10UserspaceEmulator: Implement clock_settime syscallBrendan Coles
2021-01-10TestTypeTraits: Fix incorrectly namespaced nullptr_tLenny Maiorani
Problem: - Clang ToT fails to build `AK/Tests/TestTypeTraits.cpp` because `nullptr_t` is missing the `std` namespace qualifier. Solution: - Prepend the namespace qualifier.
2021-01-10LibLine: Implement support for C-V<key>AnotherTest
This commit adds support for inserting in a "verbatim" mode where a single uninterpreted key is appended to the buffer. As this allows the user to input control characters, all control characters except \n (^M) are rendered in their caret form, with reverse video (SGR 7) applied to it. To not break cursor movement, the concept of "masked" characters is introduced to the StringMetrics interface, which can be mostly ignored by the rest of the system. It should be noted that unlike some other line editing libraries, LibLine does _not_ render a hard tab as a tab, but rather as '^I', which greatly simplifies cursor handling.
2021-01-10LibVT: Respect the Negative attribute when drawing textAnotherTest
This makes the "reverse video" SGR actually work.
2021-01-10AK: Make MappedFile heap-allocated and ref-countedAndreas Kling
Let's adapt this class a bit better to how it's actually being used. Instead of having valid/invalid states and storing an error in case it's invalid, a MappedFile is now always valid, and the factory function that creates it will return an OSError if mapping fails.
2021-01-10LibCore: Use OSError in get_password() return typeAndreas Kling
2021-01-10AK: Add AK::OSError, a wrapper for errno codesAndreas Kling
This is a strongly typed carrier for "errno" error codes, intended for use in return types, e.g Result<String, OSError>.
2021-01-10Base: Change anon's default password from "foo\n" to just "foo".Emanuele Torre
2021-01-10LibCore: get_password() now removes the trailing '\n' read by getline()Emanuele Torre
This avoids unintentionally adding a newline character at the end of user passwords when they are set using passwd(1). I also fixed these two issues: - The return value of getline() was being saved in an `int` variable instead of in a `ssize_t` variable; I replaced the `int` keyword with `auto` to fix this issue. - Prior to this patch, get_password() could potentially return tcsetattr()'s errno instead of getline()'s errno in case of an error. We now make sure it always returns the right errno in case of an error.
2021-01-10Meta: Only complain about linter tools if relevant files have changedAndrew Kaster
2021-01-10Kernel+SystemServer+CrashDaemon: Better control where we put core dumpsAndreas Kling
SystemServer now creates the /tmp/coredump and /tmp/profiler_coredumps directories at startup, ensuring that they are owned by root, and with basic 0755 permissions. The kernel will also now refuse to put core dumps in a directory that doesn't fulfill the following criteria: - Owned by 0:0 - Directory with sticky bit not set - 0755 permissions Fixes #4435 Fixes #4850
2021-01-10LibCore: Don't try to unlink stale sockets in /tmp/rpc/Andreas Kling
This was very obviously racy and would only succeed if we already own the socket anyway. (And if we do, we can bind to it without unlinking!) Work towards #4876.
2021-01-10SystemServer+LibCore: Move /tmp/rpc/ directory creation to SystemServerAndreas Kling
This doesn't solve half of the problems with /tmp/rpc, but this way we can at least make it sticky instead of having it fully world-writable and owned by whoever was the first to bind an RPC socket.
2021-01-10Kernel: Don't allow non-root, non-owners to rmdir any child of stickyAndreas Kling
We were not handling sticky parents properly in sys$rmdir(). Child directories of a sticky parent should not be rmdir'able by just anyone. Only the owner and root. Fixes #4875.
2021-01-10Everywhere: Convert a bunch of dbgprintf() to dbgln()Andreas Kling
2021-01-10LibVT: Don't assert if ioctl(TIOCSWINSZ) failsAndreas Kling
This ioctl can fail if we're resizing the terminal right when the shell inside it has exited. Instead of throwing up a crash reporter, whine a little bit in the debug log and exit cleanly moments later.
2021-01-10LibELF: Convert many dbgprintf() to dbgln() and tweak debug macro nameAndreas Kling
2021-01-10LibLine: It's okay to be interrupted while reading the DSR responseAnotherTest
Fixes #4855.
2021-01-10Shell: Fix completing barewords with escapesAnotherTest
e.g. completing `foo\ bar` now works as expected.
2021-01-10LibLine: Don't clear the displayed buffer when interruptedAnotherTest
Since we always restart on a new line, there's no reason to clear the previous lines.
2021-01-10LibLine: Unregister signal handlers on destructionAnotherTest
This fixes an issue that shows up as a nice crash when "^R<enter>^C", which is actually the event loop trying to call into a deleted object (the search editor).
2021-01-09passwd: Drop "tty" pledge promise after getting password from userAndreas Kling
This leaves us with a total pledge of "stdio" when writing to /etc/passwd and /etc/shadow which is kinda neat. :^)
2021-01-09su: Drop "tty" pledge promise after getting password from userAndreas Kling
There's not much work left to do at this point, but let's be strict.
2021-01-09passwd+su: Convert fprintf(stderr, ...) to warnln()Andreas Kling
2021-01-09Ext2FS: Zero out new space when growing an inodeAndreas Kling
Before this change, truncating an Ext2FS inode to a larger size than it was before would give you uninitialized on-disk data. Fix this by zeroing out all the new space when doing an inode resize. This is pretty naively implemented via Inode::write_bytes() and there's lots of room for cleverness here in the future.
2021-01-09Ext2FS: Convert dbg() to dbgln()Andreas Kling
Also remove some dbg()'s that were printing incorrect information.
2021-01-09LibCore: Harden signal handling code to be called in global destrcutorsTom
Move some more complex globals into a Singleton, which allows it being used from global destructors. It solves problems where some global variables, such as HashMaps may already be deleted, triggering crashes trying to use them.
2021-01-09AK: Add static Singleton::get function to allow destructible globalsTom
This enable using global raw pointers rather than Singleton objects, which solves some problems because global Singleton object could be deleted when destructors are run.