mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
nologin: Use proper format strings with out() and outln()
1. Don't use the sv literal as this bypasses CheckedFormatString. 2. Don't use the content of a file as the format string. If the file contains "{}", the program will crash.
This commit is contained in:
parent
a80da456a5
commit
bda737fde7
1 changed files with 3 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -14,10 +15,10 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
|
||||
auto file_or_error = Core::Stream::File::open("/etc/nologin"sv, Core::Stream::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
outln("This account is currently not available."sv);
|
||||
outln("This account is currently not available.");
|
||||
} else {
|
||||
auto message_from_file = TRY(file_or_error.value()->read_all());
|
||||
out(message_from_file);
|
||||
out("{}", StringView { message_from_file });
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue