diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:25:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:25:12 +0000 |
commit | 827a4c3faa27e0c186452585b15094eee1119085 (patch) | |
tree | e6a08b0c767863d66f7d4a9de80db5edc7db29be /winpr/libwinpr/library | |
parent | Releasing progress-linux version 3.3.0+dfsg1-1~progress7.99u1. (diff) | |
download | freerdp3-827a4c3faa27e0c186452585b15094eee1119085.tar.xz freerdp3-827a4c3faa27e0c186452585b15094eee1119085.zip |
Merging upstream version 3.5.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'winpr/libwinpr/library')
-rw-r--r-- | winpr/libwinpr/library/library.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/winpr/libwinpr/library/library.c b/winpr/libwinpr/library/library.c index 307dc20..0fa1fd1 100644 --- a/winpr/libwinpr/library/library.c +++ b/winpr/libwinpr/library/library.c @@ -274,18 +274,17 @@ DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) if (!hModule) { - char buffer[4096]; + char buffer[4096] = { 0 }; sprintf_s(path, ARRAYSIZE(path), "/proc/%d/exe", getpid()); - status = readlink(path, buffer, sizeof(buffer)); + status = readlink(path, buffer, ARRAYSIZE(buffer) - 1); - if (status < 0) + if ((status < 0) || (status >= ARRAYSIZE(buffer))) { SetLastError(ERROR_INTERNAL_ERROR); return 0; } - buffer[status] = '\0'; - length = strnlen(buffer, sizeof(buffer)); + length = strnlen(buffer, ARRAYSIZE(buffer)); if (length < nSize) { |