advapi32: sign-compare fixes

Joris Huizer joris_huizer at yahoo.com
Wed Feb 7 09:56:46 CST 2007


Skipped content of type multipart/alternative-------------- next part --------------
>From f6b025555a6aa82846d0b287aff236450b4c15d9 Mon Sep 17 00:00:00 2001
From: Joris Huizer <jorishuizer at debian.(none)>
Date: Wed, 7 Feb 2007 16:57:35 +0100
Subject: [PATCH] advapi32: sign compare fixes
To: wine-patches <wine-patches at winehq.org>

---
 dlls/advapi32/crypt.c        |    2 +-
 dlls/advapi32/crypt_lmhash.c |    6 +++---
 dlls/advapi32/registry.c     |    4 ++--
 dlls/advapi32/security.c     |   16 ++++++++--------
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c
index 27ca768..90b9f06 100644
--- a/dlls/advapi32/crypt.c
+++ b/dlls/advapi32/crypt.c
@@ -146,7 +146,7 @@ static inline BOOL CRYPT_UnicodeToANSI(L
  */
 static inline BOOL CRYPT_ANSIToUnicode(LPCSTR str, LPWSTR* wstr, int wstrsize)
 {
-	int wcount;
+	unsigned int wcount;
 
 	if (!str)
 	{
diff --git a/dlls/advapi32/crypt_lmhash.c b/dlls/advapi32/crypt_lmhash.c
index a7e8e55..334679c 100644
--- a/dlls/advapi32/crypt_lmhash.c
+++ b/dlls/advapi32/crypt_lmhash.c
@@ -196,7 +196,7 @@ NTSTATUS WINAPI SystemFunction004(const
          unsigned int  ui[2];
     } data;
     unsigned char deskey[7];
-    int crypt_len, ofs;
+    unsigned int crypt_len, ofs;
 
     if (key->Length<=0)
         return STATUS_INVALID_PARAMETER_2;
@@ -218,7 +218,7 @@ NTSTATUS WINAPI SystemFunction004(const
 
     CRYPT_DEShash(out->Buffer, deskey, data.uc);
 
-    for(ofs=0; ofs<(crypt_len-8); ofs+=8)
+    for(ofs=0; ofs + 8 < crypt_len; ofs+=8)
         CRYPT_DEShash(out->Buffer+8+ofs, deskey, in->Buffer+ofs);
 
     memset(data.uc, 0, sizeof data.uc);
@@ -255,7 +255,7 @@ NTSTATUS WINAPI SystemFunction005(const
          unsigned int  ui[2];
     } data;
     unsigned char deskey[7];
-    int ofs, crypt_len;
+    unsigned int ofs, crypt_len;
 
     if (key->Length<=0)
         return STATUS_INVALID_PARAMETER_2;
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 54b0bfb..f611781 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -445,7 +445,7 @@ LONG WINAPI RegEnumKeyExW( HKEY hkey, DW
     DWORD total_size;
 
     TRACE( "(%p,%d,%p,%p(%d),%p,%p,%p,%p)\n", hkey, index, name, name_len,
-           name_len ? *name_len : -1, reserved, class, class_len, ft );
+           name_len ? (int)*name_len : -1, reserved, class, class_len, ft );
 
     if (reserved) return ERROR_INVALID_PARAMETER;
     if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
@@ -509,7 +509,7 @@ LONG WINAPI RegEnumKeyExA( HKEY hkey, DW
     DWORD total_size;
 
     TRACE( "(%p,%d,%p,%p(%d),%p,%p,%p,%p)\n", hkey, index, name, name_len,
-           name_len ? *name_len : -1, reserved, class, class_len, ft );
+           name_len ? (int)*name_len : -1, reserved, class, class_len, ft );
 
     if (reserved) return ERROR_INVALID_PARAMETER;
     if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index 5d66d0a..e0720ae 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -750,7 +750,7 @@ CreateWellKnownSid( WELL_KNOWN_SID_TYPE
                     PSID pSid,
                     DWORD* cbSid)
 {
-    int i;
+    unsigned int i;
     TRACE("(%d, %s, %p, %p)\n", WellKnownSidType, debugstr_sid(DomainSid), pSid, cbSid);
 
     if (DomainSid != NULL) {
@@ -789,7 +789,7 @@ CreateWellKnownSid( WELL_KNOWN_SID_TYPE
 BOOL WINAPI
 IsWellKnownSid( PSID pSid, WELL_KNOWN_SID_TYPE WellKnownSidType )
 {
-    int i;
+    unsigned int i;
     TRACE("(%s, %d)\n", debugstr_sid(pSid), WellKnownSidType);
 
     for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
@@ -1603,7 +1603,7 @@ LookupPrivilegeNameA( LPCSTR lpSystemNam
         if (ret)
         {
             /* Windows crashes if cchName is NULL, so will I */
-            int len = WideCharToMultiByte(CP_ACP, 0, lpNameW, -1, lpName,
+            unsigned int len = WideCharToMultiByte(CP_ACP, 0, lpNameW, -1, lpName,
              *cchName, NULL, NULL);
 
             if (len == 0)
@@ -1892,7 +1892,7 @@ LookupAccountSidW(
 	IN OUT LPDWORD domainSize,
 	OUT PSID_NAME_USE name_use )
 {
-    int i, j;
+    unsigned int i, j;
     const WCHAR * ac = NULL;
     const WCHAR * dm = NULL;
     SID_NAME_USE use = 0;
@@ -1995,11 +1995,11 @@ LookupAccountSidW(
 
     if (dm) {
         BOOL status = TRUE;
-        if (*accountSize > lstrlenW(ac)) {
+        if (*accountSize > (unsigned)lstrlenW(ac)) {
             if (account)
                 lstrcpyW(account, ac);
         }
-        if (*domainSize > lstrlenW(dm)) {
+        if (*domainSize > (unsigned)lstrlenW(dm)) {
             if (domain)
                 lstrcpyW(domain, dm);
         }
@@ -3805,7 +3805,7 @@ static DWORD ComputeStringSidSize(LPCWST
     }
     else /* String constant format  - Only available in winxp and above */
     {
-        int i;
+        unsigned int i;
 
         for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
             if (!strncmpW(WellKnownSids[i].wstr, StringSid, 2))
@@ -3899,7 +3899,7 @@ static BOOL ParseStringSidToSid(LPCWSTR
     }
     else /* String constant format  - Only available in winxp and above */
     {
-        int i;
+        unsigned int i;
         pisid->Revision = SDDL_REVISION;
 
         for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
-- 
1.4.4



More information about the wine-patches mailing list