mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
paste: Don't read past clipboard data buffer size
ByteBuffer is not null-terminated (anymore), this is another one of those bugs. Also use the new format functions while we're here. Fixes #4558.
This commit is contained in:
parent
74fa894994
commit
4395e1b240
Notes:
sideshowbarker
2024-07-19 00:34:33 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/4395e1b2403 Pull-request: https://github.com/SerenityOS/serenity/pull/4560 Issue: https://github.com/SerenityOS/serenity/issues/4558
@ -28,7 +28,6 @@
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
@ -48,17 +47,17 @@ int main(int argc, char* argv[])
|
||||
auto data_and_type = clipboard.data_and_type();
|
||||
|
||||
if (data_and_type.mime_type.is_null()) {
|
||||
fprintf(stderr, "Nothing copied\n");
|
||||
warnln("Nothing copied");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!print_type) {
|
||||
printf("%s", data_and_type.data.data());
|
||||
out("{}", StringView(data_and_type.data));
|
||||
// Append a newline to text contents, unless the caller says otherwise.
|
||||
if (data_and_type.mime_type.starts_with("text/") && !no_newline)
|
||||
putchar('\n');
|
||||
outln();
|
||||
} else {
|
||||
printf("%s\n", data_and_type.mime_type.characters());
|
||||
outln("{}", data_and_type.mime_type);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user