s4-dsdb: check the type of session_info from the opaque
authorAndrew Tridgell <tridge@samba.org>
Tue, 17 Aug 2010 04:55:23 +0000 (14:55 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 17 Aug 2010 11:21:51 +0000 (21:21 +1000)
we saw a crash with a bad pointer here, and this may help track it
down

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/dsdb/samdb/ldb_modules/util.c

index fda1733f62cae9fc3e566d8f063628fc42764886..23a8da2228c726fb0df17eb876825f5da723ac4d 100644 (file)
@@ -906,7 +906,7 @@ bool dsdb_module_am_system(struct ldb_module *module)
 {
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct auth_session_info *session_info
-               = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo");
+               = talloc_get_type(ldb_get_opaque(ldb, "sessionInfo"), struct auth_session_info);
        return security_session_user_level(session_info, NULL) == SECURITY_SYSTEM;
 }
 
@@ -914,7 +914,7 @@ bool dsdb_module_am_administrator(struct ldb_module *module)
 {
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct auth_session_info *session_info
-               = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo");
+               = talloc_get_type(ldb_get_opaque(ldb, "sessionInfo"), struct auth_session_info);
        return security_session_user_level(session_info, NULL) == SECURITY_ADMINISTRATOR;
 }