kernel32: Fix out of bounds access in DnsHostnameToComputerName[AW].

This commit is contained in:
André Hentschel 2014-01-29 23:41:28 +01:00 committed by Alexandre Julliard
parent 2ef27a2322
commit bbd71d6b72
1 changed files with 4 additions and 4 deletions

View File

@ -688,7 +688,7 @@ BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR hostname,
if (len > MAX_COMPUTERNAME_LENGTH) if (len > MAX_COMPUTERNAME_LENGTH)
len = MAX_COMPUTERNAME_LENGTH; len = MAX_COMPUTERNAME_LENGTH;
if (*size < len) if (*size < len + 1)
{ {
*size = len; *size = len;
return FALSE; return FALSE;
@ -696,7 +696,7 @@ BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR hostname,
if (!computername) return FALSE; if (!computername) return FALSE;
memcpy( computername, hostname, len ); memcpy( computername, hostname, len );
computername[len + 1] = 0; computername[len] = 0;
return TRUE; return TRUE;
} }
@ -716,7 +716,7 @@ BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname,
if (len > MAX_COMPUTERNAME_LENGTH) if (len > MAX_COMPUTERNAME_LENGTH)
len = MAX_COMPUTERNAME_LENGTH; len = MAX_COMPUTERNAME_LENGTH;
if (*size < len) if (*size < len + 1)
{ {
*size = len; *size = len;
return FALSE; return FALSE;
@ -724,6 +724,6 @@ BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname,
if (!computername) return FALSE; if (!computername) return FALSE;
memcpy( computername, hostname, len * sizeof(WCHAR) ); memcpy( computername, hostname, len * sizeof(WCHAR) );
computername[len + 1] = 0; computername[len] = 0;
return TRUE; return TRUE;
} }