From bda737fde76da947ab9ef26e85235bfd2fed26e0 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 31 Oct 2022 09:04:01 -0400 Subject: [PATCH] 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. --- Userland/Utilities/nologin.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/nologin.cpp b/Userland/Utilities/nologin.cpp index 9e58726712..0808b4ce37 100644 --- a/Userland/Utilities/nologin.cpp +++ b/Userland/Utilities/nologin.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -14,10 +15,10 @@ ErrorOr 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;