idmap_cache: Only touch "sid" on success in find_xid_to_sid
authorVolker Lendecke <vl@samba.org>
Tue, 26 Feb 2019 11:46:39 +0000 (12:46 +0100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 13 Mar 2019 08:34:14 +0000 (08:34 +0000)
Why? This makes the negative mapping condition (is_null_sid) more
explicit in the code.

The callers in lookup_sid initialized "psid" anyway before, and the ones
in wb_xids2sids now do as well. This is more in line with other APIs we
have: Only touch output parameters if you have something to say.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13813
(cherry picked from commit 4faf3e9f6da7515fc263d79f77226d105c2f8524)

source3/lib/idmap_cache.c
source3/winbindd/wb_xids2sids.c

index 244a727e01bda72f0353df8660e85b03aa10c6b7..10c1e8b1e7a70df8f1714f40d38d2ebde9ef1b50 100644 (file)
@@ -203,13 +203,11 @@ static void idmap_cache_xid2sid_parser(const struct gencache_timeout *timeout,
                (struct idmap_cache_xid2sid_state *)private_data;
        char *value;
 
-       ZERO_STRUCTP(state->sid);
-       state->ret = false;
-
        if ((blob.length == 0) || (blob.data[blob.length-1] != 0)) {
                /*
                 * Not a string, can't be a valid mapping
                 */
+               state->ret = false;
                return;
        }
 
@@ -219,6 +217,7 @@ static void idmap_cache_xid2sid_parser(const struct gencache_timeout *timeout,
                /*
                 * Return NULL SID, see comment to uid2sid
                 */
+               *state->sid = (struct dom_sid) {0};
                state->ret = true;
        } else {
                state->ret = string_to_sid(state->sid, value);
index fdd98a3d9bf22e7ba0871f2763330bdaa577adec..4aaabc1c15bec633b475fe1ad109a7aff543f52f 100644 (file)
@@ -465,7 +465,7 @@ struct tevent_req *wb_xids2sids_send(TALLOC_CTX *mem_ctx,
                uint32_t i;
 
                for (i=0; i<num_xids; i++) {
-                       struct dom_sid sid;
+                       struct dom_sid sid = {0};
                        bool ok, expired;
 
                        switch (xids[i].type) {