diff --git a/ChangeLog b/ChangeLog index 6071a3f1..46b5fbb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ v0.91.10 21-Aug-2007 Added extra debug info in pack function. Only adjust LR pointers if they must be changed to save some disk i/o. + LastRead records that don't belong to a valid user are + purged. mbcico: Fixed a lot of compiler warnings. diff --git a/lib/jammsg.c b/lib/jammsg.c index c8122e51..3ea16d16 100644 --- a/lib/jammsg.c +++ b/lib/jammsg.c @@ -743,20 +743,30 @@ void JAM_Pack(void) LR.HighReadMsg = jamHdrInfo.ActiveMsgs; Syslog('m', "JAM_Pack %s recno %d user %d HighRead is reset to %d", BaseName, i, LR.UserID, LR.HighReadMsg); } - Syslog('m', "JAM_Pack check user record %d", LR.UserID); if (usrF) { - Syslog('m', "JAM_Pack get user record %d at %d", LR.UserID, usrhdr.hdrsize + (usrhdr.recsize * LR.UserID)); + /* + * Search user record for LR pointer. If the record is valid and the + * user still exists then copy the LR record, else we drop it. + */ fseek(usrF, usrhdr.hdrsize + (usrhdr.recsize * LR.UserID), SEEK_SET); memset(&usr, 0, sizeof(usr)); if (fread(&usr, usrhdr.recsize, 1, usrF) == 1) { mycrc = StringCRC32(tl(usr.sUserName)); - Syslog('m', "JAM_Pack got user record %d \"%s\", crc %s", LR.UserID, usr.sUserName, - (mycrc == LR.UserCRC) ? "Ok":"Error"); + if (mycrc == LR.UserCRC) { + write(fdnJlr, &LR, sizeof(lastread)); + } else { + Syslog('-', "JAM_Pack %s purged LR record %d", BaseName, i); + } } else { - Syslog('m', "JAM_Pack read error"); + Syslog('-', "JAM_Pack %s purged LR record %d", BaseName, i); } + } else { + /* + * Should not be possible, but simply write LR records + * if no user data is available. + */ + write(fdnJlr, &LR, sizeof(lastread)); } - write(fdnJlr, &LR, sizeof(lastread)); } } if (usrF)