From: Wilfried Goesgens Date: Sat, 26 May 2012 10:16:53 +0000 (+0200) Subject: make shure all of the struct is initialized properly if the DB doesn't give us enough... X-Git-Tag: v8.12~64 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=c54bcf54bb3a1c23f81d830142b7fd02c91503c1 make shure all of the struct is initialized properly if the DB doesn't give us enough to fill it. --- 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));