s3:idmap_tdb: fix hwm-handling to use uint32 consistently
authorMichael Adam <obnox@samba.org>
Thu, 6 Oct 2011 18:19:41 +0000 (20:19 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 11 Oct 2011 12:17:58 +0000 (14:17 +0200)
The initialization code user int32, later writes used uint32...

source3/winbindd/idmap_tdb.c

index 5d5f97899dbe9b8636d5a1ea27d0db65c082fa96..ec6b0a8e9072f75d48c2e31c5b2e29193857f9a1 100644 (file)
@@ -241,16 +241,17 @@ static NTSTATUS idmap_tdb_init_hwm(struct idmap_domain *dom)
        bool update_uid = false;
        bool update_gid = false;
        struct idmap_tdb_context *ctx;
+       bool status;
 
        ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context);
 
-       low_uid = dbwrap_fetch_int32(ctx->db, HWM_USER);
-       if (low_uid == -1 || low_uid < dom->low_id) {
+       status = dbwrap_fetch_uint32(ctx->db, HWM_USER, &low_uid);
+       if (!status || low_uid < dom->low_id) {
                update_uid = true;
        }
 
-       low_gid = dbwrap_fetch_int32(ctx->db, HWM_GROUP);
-       if (low_gid == -1 || low_gid < dom->low_id) {
+       status = dbwrap_fetch_uint32(ctx->db, HWM_GROUP, &low_gid);
+       if (!status || low_gid < dom->low_id) {
                update_gid = true;
        }
 
@@ -264,7 +265,7 @@ static NTSTATUS idmap_tdb_init_hwm(struct idmap_domain *dom)
        }
 
        if (update_uid) {
-               ret = dbwrap_store_int32(ctx->db, HWM_USER, dom->low_id);
+               ret = dbwrap_store_uint32(ctx->db, HWM_USER, dom->low_id);
                if (ret == -1) {
                        dbwrap_transaction_cancel(ctx->db);
                        DEBUG(0, ("Unable to initialise user hwm in idmap "
@@ -274,7 +275,7 @@ static NTSTATUS idmap_tdb_init_hwm(struct idmap_domain *dom)
        }
 
        if (update_gid) {
-               ret = dbwrap_store_int32(ctx->db, HWM_GROUP, dom->low_id);
+               ret = dbwrap_store_uint32(ctx->db, HWM_GROUP, dom->low_id);
                if (ret == -1) {
                        dbwrap_transaction_cancel(ctx->db);
                        DEBUG(0, ("Unable to initialise group hwm in idmap "
@@ -389,11 +390,12 @@ static NTSTATUS idmap_tdb_allocate_id_action(struct db_context *db,
        NTSTATUS ret;
        struct idmap_tdb_allocate_id_context *state;
        uint32_t hwm;
+       bool ret2;
 
        state = (struct idmap_tdb_allocate_id_context *)private_data;
 
-       hwm = dbwrap_fetch_int32(db, state->hwmkey);
-       if (hwm == -1) {
+       ret2 = dbwrap_fetch_uint32(db, state->hwmkey, &hwm);
+       if (!ret2) {
                ret = NT_STATUS_INTERNAL_DB_ERROR;
                goto done;
        }