From: Volker Lendecke Date: Tue, 6 May 2008 11:53:45 +0000 (+0200) Subject: Fix a panic in the [ug]id2sid valgrind bug fix X-Git-Tag: samba-4.0.0alpha6~801^2~1499 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3643aa9a63588b60797cb13e00a46e6c5dc845e8;p=thirdparty%2Fsamba.git Fix a panic in the [ug]id2sid valgrind bug fix Always, always run "make test" before pushing stuff :-) (This used to be commit 1444db8be1de00a3e9c805f1accd8f1f4670d729) --- diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c index debd67b136e..a7175b9647f 100644 --- a/source3/passdb/lookup_sid.c +++ b/source3/passdb/lookup_sid.c @@ -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; }