From b498f06a2b5242976387ca04ef9712e00f81dbb7 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 15 Nov 2013 12:34:55 +0100 Subject: [PATCH] MSG: safeguard: terminate the message buffer if we find an unclean message in the DB. --- citadel/msgbase.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 776680b6d..1fff6dc47 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1129,6 +1129,13 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body) ret->cm_anon_type = *mptr++; /* Anon type byte */ ret->cm_format_type = *mptr++; /* Format type byte */ + + if (dmsgtext->ptr[dmsgtext->len - 1] != '\0') + { + MSG_syslog(LOG_ERR, "CtdlFetchMessage(%ld, %d) Forcefully terminating message!!\n", msgnum, with_body); + dmsgtext->ptr[dmsgtext->len - 1] = '\0'; + } + /* * The rest is zero or more arbitrary fields. Load them in. * We're done when we encounter either a zero-length field or -- 2.30.2