idmap_autorid: fix traversal of ranges to correctly exclude mapping records.
authorMichael Adam <obnox@samba.org>
Fri, 18 Oct 2013 14:26:41 +0000 (16:26 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 21 Oct 2013 17:48:40 +0000 (19:48 +0200)
When listing all ranges with "net idmap get ranges", the database records
of the form "S-1-5-10" --> "GID 100016" were treated here as rangee mapings,
resulting in an faulty printout like this: "RANGE 541346119: S-1-5-10".

This patch fixes this by adding a filter that checks the size of the
value datablob.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Oct 21 19:48:40 CEST 2013 on sn-devel-104

source3/winbindd/idmap_autorid_tdb.c

index bbfa5b04b63baf5c5211e9b7b2ecf17170613d4f..7d3275e78df5f04f5e8b21bc09a554b4f953f772 100644 (file)
@@ -962,6 +962,14 @@ static int idmap_autorid_visit_domain_range(struct db_record *rec,
        }
 
        value = dbwrap_record_get_value(rec);
+
+       if (value.dsize != sizeof(uint32_t)) {
+               /* it might be a mapping of a well known sid */
+               DEBUG(10, ("value size %u != sizeof(uint32_t) for sid '%s', "
+                          "skipping.\n", (unsigned)value.dsize, vi->domsid));
+               goto done;
+       }
+
        rangenum = IVAL(value.dptr, 0);
 
        db = dbwrap_record_get_db(rec);