MSG: safeguard: terminate the message buffer if we find an unclean message in the DB.
authorWilfried Goesgens <dothebart@citadel.org>
Fri, 15 Nov 2013 11:34:55 +0000 (12:34 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Fri, 15 Nov 2013 11:34:55 +0000 (12:34 +0100)
citadel/msgbase.c

index 776680b6df7cd5dd04f16bd04979fe23cf07cff6..1fff6dc474d891ef3a838937d1d109f877a3f87f 100644 (file)
@@ -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