diff options
| author | Martin Ridgers <[email protected]> | 2021-09-29 15:45:31 +0200 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-09-29 16:57:32 +0200 |
| commit | 6b43d7c2117ba1861b8e76eb1e2e6ba8105e7f3e (patch) | |
| tree | 17d9daaf4c608fb83f9a7821498d8661f2e5ccb5 /zencore/filesystem.cpp | |
| parent | Changed an include path from backslashes to forward slashes (diff) | |
| download | zen-6b43d7c2117ba1861b8e76eb1e2e6ba8105e7f3e.tar.xz zen-6b43d7c2117ba1861b8e76eb1e2e6ba8105e7f3e.zip | |
readlink() parameters should not alias each other
Diffstat (limited to 'zencore/filesystem.cpp')
| -rw-r--r-- | zencore/filesystem.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index b5733c4ed..f842cbfea 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -763,14 +763,15 @@ PathFromHandle(void* NativeHandle) return FullPath; #elif ZEN_PLATFORM_LINUX - char Buffer[256]; - sprintf(Buffer, "/proc/%d/fd/%d", getpid(), int(uintptr_t(NativeHandle))); - ssize_t BytesRead = readlink(Buffer, Buffer, sizeof(Buffer) - 1); + char Link[256]; + char Path[64]; + sprintf(Path, "/proc/%d/fd/%d", getpid(), int(uintptr_t(NativeHandle))); + ssize_t BytesRead = readlink(Path, Link, sizeof(Link) - 1); if (BytesRead <= 0) return std::filesystem::path(); - Buffer[BytesRead] = '\0'; - return Buffer; + Link[BytesRead] = '\0'; + return Link; #else # error Unimplemented platform #endif // ZEN_PLATFORM_WINDOWS @@ -785,14 +786,15 @@ GetRunningExecutablePath() return {std::wstring_view(ExePath, PathLength)}; #elif ZEN_PLATFORM_LINUX - char Buffer[256]; - sprintf(Buffer, "/proc/%d/exe", getpid()); - ssize_t BytesRead = readlink(Buffer, Buffer, sizeof(Buffer) - 1); + char Link[256]; + char Path[64]; + sprintf(Path, "/proc/%d/exe", getpid()); + ssize_t BytesRead = readlink(Path, Link, sizeof(Link) - 1); if (BytesRead < 0) return {}; - Buffer[BytesRead] = '\0'; - return Buffer; + Link[BytesRead] = '\0'; + return Link; #else # error Unimplemented platform #endif // ZEN_PLATFORM_WINDOWS |