From bf6fcbd8d8c9a6f76786e6df86ff61a9958a6a84 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 26 May 2012 14:04:45 +0200 Subject: [PATCH] - dump_message() isn't used anymore; remove it. - fix potential NULL-pointer dereferencing. --- citadel/msgbase.c | 43 +------------------------------------------ citadel/msgbase.h | 1 - 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 1e4155a08..706230774 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2983,47 +2983,6 @@ void serialize_message(struct ser_ret *ret, /* return values */ } -/* - * Serialize a struct CtdlMessage into the format used on disk and network. - * - * This function loads up a "struct ser_ret" (defined in server.h) which - * contains the length of the serialized message and a pointer to the - * serialized message in memory. THE LATTER MUST BE FREED BY THE CALLER. - */ -void dump_message(struct CtdlMessage *msg, /* unserialized msg */ - long Siz) /* how many chars ? */ -{ - int i; - static char *forder = FORDER; - char *buf; - - /* - * Check for valid message format - */ - if (is_valid_message(msg) == 0) { - struct CitContext *CCC = CC; - MSGM_syslog(LOG_ERR, "dump_message() aborting due to invalid message\n"); - return; - } - - buf = (char*) malloc (Siz + 1); - - for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL) { - snprintf (buf, Siz, " msg[%c] = %s ...\n", (char) forder[i], - msg->cm_fields[(int)forder[i]]); - if (client_write (buf, strlen(buf)) == -1) - { - struct CitContext *CCC = CC; - MSGM_syslog(LOG_ERR, "dump_message(): aborting due to write failure.\n"); - return; - } - } - - return; -} - - - /* * Check to see if any messages already exist in the current room which * carry the same Exclusive ID as this one. If any are found, delete them. @@ -4728,7 +4687,7 @@ int CtdlDeleteMessages(char *room_name, /* which room */ cdb_free(cdbfr); } if (num_msgs > 0) { - int have_contenttype = !IsEmptyStr(content_type); + int have_contenttype = (content_type != NULL) && !IsEmptyStr(content_type); int have_delmsgs = (num_dmsgnums == 0) || (dmsgnums == NULL); int have_more_del = 1; diff --git a/citadel/msgbase.h b/citadel/msgbase.h index f74c64b73..017942f8d 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -144,7 +144,6 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body); void CtdlFreeMessage(struct CtdlMessage *msg); void CtdlFreeMessageContents(struct CtdlMessage *msg); void serialize_message(struct ser_ret *, struct CtdlMessage *); -void dump_message(struct CtdlMessage *msg, long Siz); int is_valid_message(struct CtdlMessage *); void ReplicationChecks(struct CtdlMessage *); int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs, -- 2.30.2