From 0e574d5a8d0e1aa250def6b097c69707df101f77 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 2 May 2004 12:19:52 +0000 Subject: [PATCH] Added extra check in mbfile check --- ChangeLog | 2 ++ mbfido/mbfcheck.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 194fdead..de20f247 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,6 +40,8 @@ v0.51.4 11-Apr-2004 mbfile: The toberep command now logs the toberep.data in the debug logfile. + Mbfile check will abort if a header of a files database is + corrupt. mbnntp: New program, news server to read echomail with a news client. diff --git a/mbfido/mbfcheck.c b/mbfido/mbfcheck.c index a3e1d974..899c676d 100644 --- a/mbfido/mbfcheck.c +++ b/mbfido/mbfcheck.c @@ -190,7 +190,19 @@ void Check(void) fwrite(&fdbhdr, sizeof(fdbhdr), 1, pFile); } else { fread(&fdbhdr, sizeof(fdbhdr), 1, pFile); - } + } + + /* + * We don't do any upgrade, so the header must be correct. + */ + if (fdbhdr.hdrsize != sizeof(fdbhdr)) { + Syslog('+', "fAreas hdrsize is corrupt: %d", fdbhdr.hdrsize); + return; + } + if (fdbhdr.recsize != sizeof(fdb)) { + Syslog('+', "fAreas recordsize is corrupt: %d, expected %d", fdbhdr.recsize, sizeof(fdbhdr)); + return; + } /* * Now start checking the files in the filedatabase