]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Fix a panic in the [ug]id2sid valgrind bug fix
authorVolker Lendecke <vl@samba.org>
Tue, 6 May 2008 11:53:45 +0000 (13:53 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 6 May 2008 11:56:21 +0000 (13:56 +0200)
Always, always run "make test" before pushing stuff :-)
(This used to be commit 1444db8be1de00a3e9c805f1accd8f1f4670d729)

source3/passdb/lookup_sid.c

index debd67b136e9550ee52d89e5dc7b418a4cb512d8..a7175b9647fa4af2a4f14ce900fab9d519ed5e7d 100644 (file)
@@ -1012,8 +1012,9 @@ static bool fetch_sid_from_uid_cache(DOM_SID *psid, uid_t uid)
                return false;
        }
 
-       SMB_ASSERT(cache_value.length == sizeof(*psid));
-       memcpy(psid, cache_value.data, sizeof(*psid));
+       memcpy(psid, cache_value.data, MIN(sizeof(*psid), cache_value.length));
+       SMB_ASSERT(cache_value.length >= offsetof(struct dom_sid, id_auth));
+       SMB_ASSERT(cache_value.length == ndr_size_dom_sid(psid, 0));
 
        return true;
 }
@@ -1066,8 +1067,9 @@ static bool fetch_sid_from_gid_cache(DOM_SID *psid, gid_t gid)
                return false;
        }
 
-       SMB_ASSERT(cache_value.length == sizeof(*psid));
-       memcpy(psid, cache_value.data, sizeof(*psid));
+       memcpy(psid, cache_value.data, MIN(sizeof(*psid), cache_value.length));
+       SMB_ASSERT(cache_value.length >= offsetof(struct dom_sid, id_auth));
+       SMB_ASSERT(cache_value.length == ndr_size_dom_sid(psid, 0));
 
        return true;
 }