From 142db87970231a49b40eb2ed70dc6bd943ad8d8b Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 29 Oct 2019 11:33:27 +0100 Subject: [PATCH] Removed strlen from GetComputerNameExA --- winpr/libwinpr/sysinfo/sysinfo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winpr/libwinpr/sysinfo/sysinfo.c b/winpr/libwinpr/sysinfo/sysinfo.c index c2667fe..42c3096 100644 --- a/winpr/libwinpr/sysinfo/sysinfo.c +++ b/winpr/libwinpr/sysinfo/sysinfo.c @@ -424,7 +424,7 @@ BOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize) BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPSTR lpBuffer, LPDWORD lpnSize) { - int length; + size_t length; char hostname[256]; if (!lpnSize) @@ -449,7 +449,7 @@ BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPSTR lpBuffer, LPDWORD l if (gethostname(hostname, sizeof(hostname)) == -1) return FALSE; - length = (int) strlen(hostname); + length = strnlen(hostname, sizeof(hostname)); switch (NameType) { @@ -461,14 +461,14 @@ BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPSTR lpBuffer, LPDWORD l case ComputerNamePhysicalDnsFullyQualified: if ((*lpnSize <= (DWORD) length) || !lpBuffer) { - *lpnSize = length + 1; + *lpnSize = (DWORD)(length + 1); SetLastError(ERROR_MORE_DATA); return FALSE; } CopyMemory(lpBuffer, hostname, length); lpBuffer[length] = '\0'; - *lpnSize = length; + *lpnSize = (DWORD)length; break; default: -- 2.7.4