=?UTF-8?Q?Andr=C3=A9=20Hentschel=20?=: kernel32: Fix out of bounds access in DnsHostnameToComputerName[AW].

Alexandre Julliard julliard at winehq.org
Thu Jan 30 13:25:25 CST 2014


Module: wine
Branch: master
Commit: bbd71d6b72497f6ab24e43548ad924747549d090
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bbd71d6b72497f6ab24e43548ad924747549d090

Author: André Hentschel <nerv at dawncrow.de>
Date:   Wed Jan 29 23:41:28 2014 +0100

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

---

 dlls/kernel32/computername.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/kernel32/computername.c b/dlls/kernel32/computername.c
index 8650440..0c81ac0 100644
--- a/dlls/kernel32/computername.c
+++ b/dlls/kernel32/computername.c
@@ -688,7 +688,7 @@ BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR hostname,
     if (len > MAX_COMPUTERNAME_LENGTH)
         len = MAX_COMPUTERNAME_LENGTH;
 
-    if (*size < len)
+    if (*size < len + 1)
     {
         *size = len;
         return FALSE;
@@ -696,7 +696,7 @@ BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR hostname,
     if (!computername) return FALSE;
 
     memcpy( computername, hostname, len );
-    computername[len + 1] = 0;
+    computername[len] = 0;
     return TRUE;
 }
 
@@ -716,7 +716,7 @@ BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname,
     if (len > MAX_COMPUTERNAME_LENGTH)
         len = MAX_COMPUTERNAME_LENGTH;
 
-    if (*size < len)
+    if (*size < len + 1)
     {
         *size = len;
         return FALSE;
@@ -724,6 +724,6 @@ BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname,
     if (!computername) return FALSE;
 
     memcpy( computername, hostname, len * sizeof(WCHAR) );
-    computername[len + 1] = 0;
+    computername[len] = 0;
     return TRUE;
 }




More information about the wine-cvs mailing list