From c54bcf54bb3a1c23f81d830142b7fd02c91503c1 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 26 May 2012 12:16:53 +0200 Subject: [PATCH] make shure all of the struct is initialized properly if the DB doesn't give us enough to fill it. --- citadel/modules/expire/serv_expire.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/citadel/modules/expire/serv_expire.c b/citadel/modules/expire/serv_expire.c index d15670074..d81880858 100644 --- a/citadel/modules/expire/serv_expire.c +++ b/citadel/modules/expire/serv_expire.c @@ -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)); -- 2.30.2