mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-12-22 19:05:30 +00:00
[Linux] Null-terminate output from readlink in Discord_Register. (#208)
* Explicitly null-terminate the output from readlink in discord_register_linux.cpp. * The return value of readlink is a signed size_t.
This commit is contained in:
parent
dfad394be0
commit
b44defe60a
|
@ -33,9 +33,11 @@ extern "C" DISCORD_EXPORT void Discord_Register(const char* applicationId, const
|
||||||
|
|
||||||
char exePath[1024];
|
char exePath[1024];
|
||||||
if (!command || !command[0]) {
|
if (!command || !command[0]) {
|
||||||
if (readlink("/proc/self/exe", exePath, sizeof(exePath)) <= 0) {
|
ssize_t size = readlink("/proc/self/exe", exePath, sizeof(exePath));
|
||||||
|
if (size <= 0 || size >= sizeof(exePath)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
exePath[size] = '\0';
|
||||||
command = exePath;
|
command = exePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue