Mikolaj Zalewski : advapi32: Make ConvertStringSidToSid not to ignore the first subauthority.

Alexandre Julliard julliard at winehq.org
Tue Sep 25 07:50:47 CDT 2007


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

Author: Mikolaj Zalewski <mikolajz at google.com>
Date:   Mon Sep 24 19:04:11 2007 -0700

advapi32: Make ConvertStringSidToSid not to ignore the first subauthority.

---

 dlls/advapi32/security.c       |    4 ++--
 dlls/advapi32/tests/security.c |    8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index 5889213..89e3d90 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -3900,12 +3900,12 @@ static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
 
         while (*StringSid)
         {
+            pisid->SubAuthority[i++] = atoiW(StringSid);
+
             while (*StringSid && *StringSid != '-')
                 StringSid++;
             if (*StringSid == '-')
                 StringSid++;
-
-            pisid->SubAuthority[i++] = atoiW(StringSid);
         }
 
         if (i != pisid->SubAuthorityCount)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 86c4c50..9e356ac 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -148,6 +148,7 @@ static void test_sid(void)
     const char noSubAuthStr[] = "S-1-5";
     unsigned int i;
     PSID psid = NULL;
+    SID *pisid;
     BOOL r;
     LPSTR str = NULL;
 
@@ -185,6 +186,13 @@ static void test_sid(void)
      "expected GetLastError() is ERROR_INVALID_SID, got %d\n",
      GetLastError() );
 
+    ok(pConvertStringSidToSidA("S-1-5-21-93476-23408-4576", &psid), "ConvertStringSidToSidA failed\n");
+    pisid = (SID *)psid;
+    ok(pisid->SubAuthorityCount == 4, "Invalid sub authority count - expected 4, got %d\n", pisid->SubAuthorityCount);
+    ok(pisid->SubAuthority[0] == 21, "Invalid subauthority 0 - expceted 21, got %d\n", pisid->SubAuthority[0]);
+    ok(pisid->SubAuthority[3] == 4576, "Invalid subauthority 0 - expceted 4576, got %d\n", pisid->SubAuthority[3]);
+    LocalFree(str);
+
     for( i = 0; i < sizeof(refs) / sizeof(refs[0]); i++ )
     {
         PISID pisid;




More information about the wine-cvs mailing list