summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2020-08-16 15:59:36 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-22 20:55:10 +0200
commit1aad0f8b16f886eedb99434eb9010dda4f0a0522 (patch)
treec0fadadfedfb857653291940f3656ac12f52d9d6 /Kernel
parent04f494fc44ec07225dd8168d48c77d9e04e520ba (diff)
downloadserenity-1aad0f8b16f886eedb99434eb9010dda4f0a0522.zip
Kernel: Stop supporting sprintf
The kernel no longer needs sprintf (which might, in theory, overflow), so we can hide the C++ declaration and make the function uncallable from within the kernel. However, libstdc++ still links against it, as libstdc++ uses it for demangling, from AK::demangle().
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/kprintf.cpp4
-rw-r--r--Kernel/kstdio.h1
2 files changed, 4 insertions, 1 deletions
diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp
index 6834ce00bd..d03388c5d1 100644
--- a/Kernel/kprintf.cpp
+++ b/Kernel/kprintf.cpp
@@ -133,6 +133,10 @@ static void buffer_putch(char*& bufptr, char ch)
*bufptr++ = ch;
}
+// Declare it, so that the symbol is exported, because libstdc++ uses it.
+// However, *only* libstdc++ uses it, and none of the rest of the Kernel.
+extern "C" int sprintf(char* buffer, const char* fmt, ...);
+
int sprintf(char* buffer, const char* fmt, ...)
{
ScopedSpinLock lock(s_log_lock);
diff --git a/Kernel/kstdio.h b/Kernel/kstdio.h
index 32f3b1adda..9f30a449f7 100644
--- a/Kernel/kstdio.h
+++ b/Kernel/kstdio.h
@@ -33,7 +33,6 @@ int dbgprintf(const char* fmt, ...);
int dbgputstr(const char*, int);
int kernelputstr(const char*, int);
int kprintf(const char* fmt, ...);
-int sprintf(char* buf, const char* fmt, ...);
int snprintf(char* buf, size_t, const char* fmt, ...);
void set_serial_debug(bool on_or_off);
int get_serial_debug();