make shure all of the struct is initialized properly if the DB doesn't give us enough...
[citadel.git] / citadel / modules / expire / serv_expire.c
index d1567007455fb65d9979cd19b7c77f36663ee396..d81880858f9a3ad648e18f0140c30286223dde2e 100644 (file)
@@ -706,15 +706,18 @@ int PurgeUseTable(void) {
        cdb_rewind(CDB_USETABLE);
        while(cdbut = cdb_next_item(CDB_USETABLE), cdbut != NULL) {
 
-       /*
-        * TODODRW: change this to create a new function time_t cdb_get_timestamp( struct cdbdata *)
-        * this will release this file from the serv_network.h
-        * Maybe it could be a macro that extracts and casts the reult
-        */
-              memcpy(&ut, cdbut->ptr,
-                    ((cdbut->len > sizeof(struct UseTable)) ?
-                     sizeof(struct UseTable) : cdbut->len));
-              cdb_free(cdbut);
+               /*
+                * TODODRW: change this to create a new function time_t cdb_get_timestamp( struct cdbdata *)
+                * this will release this file from the serv_network.h
+                * Maybe it could be a macro that extracts and casts the reult
+                */
+               if (cdbut->len > sizeof(struct UseTable))
+                       memcpy(&ut, cdbut->ptr, sizeof(struct UseTable));
+               else {
+                       memset(&ut, 0, sizeof(struct UseTable));
+                       memcpy(&ut, cdbut->ptr, cdbut->len);
+               }
+               cdb_free(cdbut);
 
                if ( (time(NULL) - ut.ut_timestamp) > USETABLE_RETAIN ) {
                        uptr = (struct UPurgeList *) malloc(sizeof(struct UPurgeList));