From d1ffdea55014bcf900a5cda175bb68356d28c6c3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 13 Apr 2020 11:58:00 +0200 Subject: [PATCH] LibC: Fix truncated strncpy() in getlogin() --- Libraries/LibC/unistd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp index d1891c146a..8b03c9df3e 100644 --- a/Libraries/LibC/unistd.cpp +++ b/Libraries/LibC/unistd.cpp @@ -538,7 +538,7 @@ char* getlogin() { static char __getlogin_buffer[256]; if (auto* passwd = getpwuid(getuid())) { - strncpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer)); + strncpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer) - 1); endpwent(); return __getlogin_buffer; }