s3: Fix bug 7253
[ira/wip.git] / source3 / passdb / login_cache.c
index cf6c796321cb094fdf1e754bbb05591e849eaa95..eba83ea686c10d29ac634695770af92d865a8a39 100644 (file)
@@ -68,6 +68,7 @@ bool login_cache_read(struct samu *sampass, struct login_cache *entry)
        char *keystr;
        TDB_DATA databuf;
        uint32_t entry_timestamp = 0, bad_password_time = 0;
+       uint16_t acct_ctrl;
 
        if (!login_cache_init()) {
                return false;
@@ -92,7 +93,7 @@ bool login_cache_read(struct samu *sampass, struct login_cache *entry)
 
        if (tdb_unpack (databuf.dptr, databuf.dsize, SAM_CACHE_FORMAT,
                        &entry_timestamp,
-                       &entry->acct_ctrl,
+                       &acct_ctrl,
                        &entry->bad_password_count,
                        &bad_password_time) == -1) {
                DEBUG(7, ("No cache entry found\n"));
@@ -100,6 +101,12 @@ bool login_cache_read(struct samu *sampass, struct login_cache *entry)
                return false;
        }
 
+       /*
+        * Deal with 32-bit acct_ctrl. In the tdb we only store 16-bit
+        * ("w" in SAM_CACHE_FORMAT). Fixes bug 7253.
+        */
+       entry->acct_ctrl = acct_ctrl;
+
        /* Deal with possible 64-bit time_t. */
        entry->entry_timestamp = (time_t)entry_timestamp;
        entry->bad_password_time = (time_t)bad_password_time;