From 7e421200073375ec2f54003182dde0aec65ed342 Mon Sep 17 00:00:00 2001 From: Sander in 't Veld Date: Fri, 27 Jul 2018 14:25:24 +0200 Subject: [PATCH] Explicitly null-terminate the output from readlink in discord_register_linux.cpp. --- src/discord_register_linux.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/discord_register_linux.cpp b/src/discord_register_linux.cpp index b10f96d..0a739a7 100644 --- a/src/discord_register_linux.cpp +++ b/src/discord_register_linux.cpp @@ -33,9 +33,13 @@ extern "C" DISCORD_EXPORT void Discord_Register(const char* applicationId, const char exePath[1024]; if (!command || !command[0]) { - if (readlink("/proc/self/exe", exePath, sizeof(exePath)) <= 0) { + size_t size = readlink("/proc/self/exe", exePath, sizeof(exePath)); + if (size <= 0) { return; } + if (size < sizeof(exePath)) { + exePath[size] = '\0'; + } command = exePath; }