s3:winbindd: do not expose negative cache idmap entries as valid mappings (bug #9002)
authorStefan Metzmacher <metze@samba.org>
Thu, 24 May 2012 07:08:21 +0000 (09:08 +0200)
committerKarolin Seeger <kseeger@samba.org>
Sat, 30 Jun 2012 11:21:07 +0000 (13:21 +0200)
metze

source3/winbindd/winbindd_sids_to_xids.c

index b3699d06f801c86d227c8d1629dd93d6e5b86cba..62f09f0d627202e50b068d86c339f55cf5351aef 100644 (file)
@@ -256,21 +256,26 @@ NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req,
 
        for (i=0; i<state->num_sids; i++) {
                char type;
-               uint64_t unix_id = (uint64_t)-1;
+               uint32_t unix_id = UINT32_MAX;
                bool found = true;
 
                if (state->cached[i].sid != NULL) {
                        unix_id = state->cached[i].xid.id;
-                       if (state->cached[i].xid.type == ID_TYPE_UID) {
+
+                       switch (state->cached[i].xid.type) {
+                       case ID_TYPE_UID:
                                type = 'U';
-                       } else {
+                               break;
+                       case ID_TYPE_GID:
                                type = 'G';
+                               break;
+                       default:
+                               found = false;
+                               break;
                        }
                } else {
                        unix_id = state->ids.ids[num_non_cached].unix_id;
-                       if (unix_id == -1) {
-                               found = false;
-                       }
+
                        switch(state->ids.ids[num_non_cached].type) {
                        case WBC_ID_TYPE_UID:
                                type = 'U';
@@ -286,10 +291,15 @@ NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req,
                                break;
                        default:
                                found = false;
+                               break;
                        }
                        num_non_cached += 1;
                }
 
+               if (unix_id == UINT32_MAX) {
+                       found = false;
+               }
+
                if (found) {
                        result = talloc_asprintf_append_buffer(
                                result, "%c%lu\n", type,