Andrew Talbot : netapi32: Fix to prevent access beyond nul terminator.

Alexandre Julliard julliard at winehq.org
Tue Aug 23 12:45:03 CDT 2011


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

Author: Andrew Talbot <andrew.talbot at talbotville.com>
Date:   Mon Aug 22 21:47:07 2011 +0100

netapi32: Fix to prevent access beyond nul terminator.

---

 dlls/netapi32/nbt.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/dlls/netapi32/nbt.c b/dlls/netapi32/nbt.c
index 1115967..404fbd9 100644
--- a/dlls/netapi32/nbt.c
+++ b/dlls/netapi32/nbt.c
@@ -1497,13 +1497,17 @@ void NetBTInit(void)
                NetBTNameEncode */
             char *ptr, *lenPtr;
 
-            for (ptr = gScopeID + 1; ptr - gScopeID < sizeof(gScopeID) && *ptr; )
+            for (ptr = gScopeID + 1, lenPtr = gScopeID; ptr - gScopeID < sizeof(gScopeID) && *ptr; ++ptr)
             {
-                for (lenPtr = ptr - 1, *lenPtr = 0;
-                     ptr - gScopeID < sizeof(gScopeID) && *ptr && *ptr != '.';
-                     ptr++)
-                    *lenPtr += 1;
-                ptr++;
+                if (*ptr == '.')
+                {
+                    lenPtr = ptr;
+                    *lenPtr = 0;
+                }
+                else
+                {
+                    ++*lenPtr;
+                }
             }
         }
         if (RegQueryValueExW(hKey, CacheTimeoutW, NULL, NULL,




More information about the wine-cvs mailing list