Commit graph

3698 commits

Author SHA1 Message Date
Andreas Kling
f43adb816e Revert "LibGfx: Re-add missing bounds-checks to Painter::draw_rect"
This reverts commit 4cf5514672.
2021-05-03 16:36:57 +02:00
Brian Gianforcaro
0726d39cb1 LibC: Fix invalid 1-byte read I introduced in dirent.
When attempting to fix the dirent code I also changed
this to use strlcpy instead of the custom string copy
loop that was there before. Looking over strlcpy it
looked like it should work when using a non null terminated
string, I obviously misinterpreted the implementation
as it will read till it finds a null terminator.

Manually null terminate the string to address this.

Gunnar found this after he fixed UserspaceEmulator.
I reproduced it locally using his branch, and also
found the memory leak I had in the unit test for the
scandir that I added, so lets fix that as well.

Reported-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-03 09:47:05 +02:00
spigwitmer
3a5f9b2f7e LibDebug: add DW_LNS_set_basic_block support
This adds support for the basic_block register to the Dwarf line
number state machine.
2021-05-03 09:01:14 +02:00
Paul Berg
bd68ca362b TextEditor: Clear the selection before deleting it
This patches fixes a crash of the Userland/TextEditor where it would
crash when deleting a range spanning two lines. This was because the
TextEditor would delete the range and modify the cursor position
before clearing the selection. This would trigger a status bar update
with the invalid selection.
2021-05-03 08:45:32 +02:00
Carlos César Neves Enumo
97d0028098 LibGUI: Debounce TextDocument undo stack
This replaces the repeating 2-sec timer with a debounced single-shot
timer on user input.
2021-05-03 08:43:10 +02:00
Gunnar Beutner
824bfa9600 DynamicLoader: Fix compiler warning
math.cpp: In function 'int64_t __moddi3(int64_t, int64_t)':
math.cpp:168:13: error: 'r' may be used uninitialized
[-Werror=maybe-uninitialized]
  168 |     return ((int64_t)r ^ s) - s; // negate if s == -1
      |             ^~~~~~~~~~
2021-05-03 08:42:39 +02:00
Gunnar Beutner
a050b43290 LibELF: Implement x86_64 relocation support
There are definitely some relocations missing and this is untested
for now.
2021-05-03 08:42:39 +02:00
Gunnar Beutner
b613817bca Userland: Fix 64-bit portability issues 2021-05-03 08:42:39 +02:00
Gunnar Beutner
fdbe66a7b4 LibELF+LibC: Support building LibELF for 64-bit targets 2021-05-03 08:42:39 +02:00
Gunnar Beutner
e468bf08b1 UserspaceEmulator: Make sure TLS allocation behavior matches kernel 2021-05-03 08:25:44 +02:00
Gunnar Beutner
92cc8a47dd UserspaceEmulator: Add missing argument for sys$allocate_tls 2021-05-03 08:25:44 +02:00
Gunnar Beutner
ce0c76dcb5 UserspaceEmulator: Add stub for sys$futex 2021-05-03 08:25:44 +02:00
Luke
8b5ea01cfb LibWeb: Use node_to_insert instead of node in Node::insert_before
It was using the passed in node instead of the node from the vector.
Fixes a crash I found while testing jQuery.
2021-05-03 08:20:02 +02:00
Matthew Olsson
4cf5514672 LibGfx: Re-add missing bounds-checks to Painter::draw_rect
This commit adds a draw_physical_line method, which is the exact same
as draw_line, except it's parameters are already transformed and
scaled. This is used by both draw_line and draw_rect, as a slight
optimization to save some work. It also fixed draw_rect not checking
whether it should draw the lines before drawing them.
2021-05-03 08:19:39 +02:00
Luke
8bafbdddc6 LibWeb: Expose Node.ownerDocument
Required by jQuery.
2021-05-02 22:51:46 +02:00
Itamar
329cb134d6 HackStudio: Show dialog on build and exit if there are unsaved changes
If the user tries to exit HackStudio, or build the project, when there
are unsaved changes in some of the editors, A Yes/No/Cancel dialog will
be shown.
2021-05-02 22:49:25 +02:00
Itamar
672b14b70d HackStudio: Add a "document dirty" indicator to the EditorWrapper 2021-05-02 22:49:25 +02:00
Itamar
7f2e1991cc HackStudio: Get rid of m_currently_open_file member
It had the following FIXME:
// FIXME: This doesn't seem compatible with multiple split editors

In practice this member was used to get the filename of the currently
active edtior. So we now get it directly from the currently active
EditorWrapper.
2021-05-02 22:49:25 +02:00
Matthew Olsson
790908ffc3 LibGfx: Add scaling methods to Bitmap 2021-05-02 22:48:06 +02:00
Matthew Olsson
4233b69ecf Color: Add interpolate method 2021-05-02 22:48:06 +02:00
Matthew Olsson
ff76a5b8d2 LibGfx: Add directional floating-point scaling to Painter
This allows the painter to be scaled separately in both directions, and
not just in integer intervals. This is crucial for proper SVG viewBox
support.

Most bitmap-related things verify the scale to be one as of now.
2021-05-02 22:48:06 +02:00
Matthew Olsson
88cfaf7bf0 LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
2021-05-02 22:48:06 +02:00
Matthew Olsson
ac238b3bd6 LibGfx: Add some helper methods to AffineTransform
Also makes some basic getters ALWAYS_INLINE and [[nodiscard]], as well
as fixing as error with the map method.
2021-05-02 22:48:06 +02:00
Brian Gianforcaro
f5c676fd86 Tests: Add unit tests for the pthread_spinlock_t API.
This change establishes a new set of LibTest based tests for validating
the functionality of our pthread implementation. The first tests added
validate the error handling for the pthread spinlock API:
 * pthread_spin_init
 * pthread_spin_lock
 * pthread_spin_try_lock
 * pthread_spin_unlock
 * pthread_spin_destroy
2021-05-02 20:59:38 +02:00
Brian Gianforcaro
9f07627f58 LibPthread: Implement pthread_spinlock_t API.
This change implements the pthread user space spinlock API. The
stress-ng Port requires a functioning version to work correctly.

To facilitate the requirements of the posix specification for the API
we implement the spinlock so that the owning tid is the value stored
in the spinlock. This gives us the proper ownership semantics needed
to implement the proper error handling.
2021-05-02 20:59:38 +02:00
Valtteri Koskivuori
5b6f36dfea LaunchServer: Only consider path in OpenURL
This resolves the crash in #6812 where the browser was trying to open a
file in the Download directory, but the check against allowed paths was
also trying to match the URL fragment.

Resolves #6812
2021-05-02 19:47:28 +02:00
Ali Mohammad Pur
b7fb12338c Shell: Only match entries from PATH when a program name is given
This commit makes the shell:
- highlight executables in the current directory as invalid, unless an
  explicit `./' is given (so, `./foo` isn't red, but `foo` is)
- not suggest executables in the current directory unless explicitly
  requested (by prepending `./`)
- not attempt to run an executable in the current directory that has
  been invoked as a program name and failed execvp().
  Note that `./foo` is still executed because it's not invoked as
  a name, but rather as a path.

Fixes the other half of #6774.
2021-05-02 19:46:33 +02:00
Ali Mohammad Pur
bda69a5f59 Shell: Replace fprintf(stderr) => warnln() 2021-05-02 19:46:33 +02:00
Ali Mohammad Pur
6a9dced790 Shell: Update shebang handling logic
This bit of code was kept unmodified since it was first implemented,
and I'm not entirely convinced that it ever actually worked :P
This commit updates the code to use "modern" classes and constructs,
and fixes an issue where the shebang would still contain the '#!'
when it was passed to execvp().
Fixes #6774.
2021-05-02 19:46:33 +02:00
Andreas Kling
68a0e4f8d5 LibGUI+HackStudio: Remove editing specific hacks from GUI::Command
Use is<T> to check for specific types of command in HackStudio instead
of cluttering up GUI::Command with specialized getters.
2021-05-02 14:49:46 +02:00
Andreas Kling
f052a66c5d WindowServer+Base: Show alternate close button for "modified" windows
Windows that are marked as modified will now have another (themable)
close button. This gives an additional visual clue that some action
will be required by the user before the window gets closed.

The default window-close-modified icon is an "X" with "..." underneath,
building on the established use of "..." in menus to signify that
additional user input will be required before an action is completed.
2021-05-02 14:17:49 +02:00
Andreas Kling
819325892a WindowServer: Minor tweaks to Window.h 2021-05-02 13:35:46 +02:00
Brian Gianforcaro
331ab52318 LibC: Implement scandir(...) to enumerate directories.
I ran into a need for this when running  stress-ng against the system.
This change implements the full functionality of scandir, where it
accepts a selection callback, as well as a comparison callback.
These can be used to trim and sort the entries from the directory
that we are being asked to enumerate. A test was also included to
validate the new functionality.
2021-05-02 13:33:41 +02:00
Brian Gianforcaro
d4d988532a LibC: Fix bugs in the population of dirent members.
While adding new functionality which used the d_reclen member
to copy a dirent, I realized that the value being populated
was incorrect. sys_ent::total_size() function calculates the
size of the sys_ent structure, but dirent is larger than sys_ent.
This causes the malloc to be too small and you end up missing
the end of the copy, which can miss the null terminator
resulting in corrupt dirent names.

Since we don't actually use the variable length member nature
of dirent on other platforms we can just use the full size of
the struct ad the d_reclen value.

Also replace the custom strcpy with the standard version.
2021-05-02 13:33:41 +02:00
Gunnar Beutner
de9b454f89 LibIPC: Make sure FDs survive when passed into a MessageBuffer 2021-05-02 13:26:07 +02:00
Andreas Kling
cc6db526a6 WindowServer+LibGUI+Taskbar: Store window progress as Optional<int>
We were previously using the magical constant -1 to signify that a
window had no progress state. Be more explicit an use an Optional. :^)
2021-05-02 10:43:39 +02:00
ry755
8af7cda17a TextEditor: Specify the starting line and column number using colons
This allows the user to specify a specific line and column number to
start at when opening a file in TextEditor through the terminal, by
adding a colon after the file name.

For example, `TextEditor ReadMe.md:10:5` will open ReadMe.md and put
the cursor on line 10 at column 5.

To ensure that the user isn't trying to open a file that actually has
colons in its name, it checks if the file exists before parsing.

Replaces the feature added in b474f49164
Closes #5589
2021-05-02 10:25:51 +02:00
Andreas Kling
68a542623f LaunchServer: Actually seal the allow-list on SealAllowList
Fixes #6804.
2021-05-02 08:17:31 +02:00
Gunnar Beutner
889359b6f9 Userland: Make IPC handlers return void if they don't have any outputs 2021-05-02 08:11:38 +02:00
Gunnar Beutner
7cf2839a26 Userland: Get rid of the OwnPtr<...> boilerplate code for IPC handlers 2021-05-02 08:11:38 +02:00
Valtteri Koskivuori
1a015dc379 HackStudio: Use common copy functions in ProjectTemplate.cpp
This removes the duplicated copy logic and uses the ones from Core::File
instead.
2021-05-02 00:22:33 +02:00
Gunnar Beutner
6cf59b6ae9 Everywhere: Turn #if *_DEBUG into dbgln_if/if constexpr 2021-05-01 21:25:06 +02:00
Valtteri Koskivuori
4e6f03a860 PixelPaint: Add fill mode for the ellipse tool
Functionality was already there, just had to hook it up!
2021-05-01 21:11:33 +02:00
Gunnar Beutner
63ff271125 Userland: Improve how traceroute reports timing data for packets
Previously we'd include the time required to do DNS resolution in the
time we'd report for traceroute packets. This would skew the times
reported.
2021-05-01 20:52:35 +02:00
Valtteri Koskivuori
370231c05c Kernel: Expose minor device numbers for keyboard and mouse
A fix for two FIXMEs, and paving the way for multi-keyboard/mouse
support, I guess.
2021-05-01 20:07:11 +02:00
Andreas Kling
6536a979d8 LibGUI: Improve a FIXME comment in TextDocument 2021-05-01 19:42:29 +02:00
Andreas Kling
a7fb50567b TextEditor: Make sure to mark the Window as unmodified after saving
This comes with a FIXME, as it would be nicer if this information
would propagate from TextDocument all the way out somehow.
2021-05-01 19:42:29 +02:00
Andreas Kling
f0cc712246 TextEditor: Use an automatic "modified" marker in the window title
This simplifies the application somewhat as we no longer need to
manually update the window title whenever the text document changes.
2021-05-01 19:42:29 +02:00
Andreas Kling
20dd5735ce WindowServer+LibGfx: Automatic "modified" markers in window titles
You can now add the string "[*]" to a window title and it will be
replaced with " (*)" if the window is modified, and with "" otherwise.
2021-05-01 19:42:29 +02:00
Andreas Kling
e9c40b0243 TextEditor: Plumb modified state from GUI::TextDocument to GUI::Window
Instead of tracking this stuff ourselves at the application level,
we now just act as an intermediary and pass along the information to
the windowing system.
2021-05-01 19:42:29 +02:00