]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/ctdlproto/serv_messages.c
Protect precious strlens, as pointed out by John Goerzen
[citadel.git] / citadel / modules / ctdlproto / serv_messages.c
index 46c540f83937652096ee6546735b1c06cfdeb163..0751e28a91ead449f721e3f30d99c26aaecdd056 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * represent messages to the citadel clients
  *
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-2015 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
 #include "internet_addressing.h"
 #include "user_ops.h"
 #include "room_ops.h"
+#include "config.h"
 
 extern char *msgkeys[];
 
 
-
 /*
  * Back end for the MSGS command: output message number only.
  */
@@ -34,7 +34,6 @@ void simple_listing(long msgnum, void *userdata)
 }
 
 
-
 /*
  * Back end for the MSGS command: output header summary.
  */
@@ -42,7 +41,7 @@ void headers_listing(long msgnum, void *userdata)
 {
        struct CtdlMessage *msg;
 
-       msg = CtdlFetchMessage(msgnum, 0);
+       msg = CtdlFetchMessage(msgnum, 0, 1);
        if (msg == NULL) {
                cprintf("%ld|0|||||\n", msgnum);
                return;
@@ -66,7 +65,7 @@ void headers_euid(long msgnum, void *userdata)
 {
        struct CtdlMessage *msg;
 
-       msg = CtdlFetchMessage(msgnum, 0);
+       msg = CtdlFetchMessage(msgnum, 0, 1);
        if (msg == NULL) {
                cprintf("%ld||\n", msgnum);
                return;
@@ -137,7 +136,7 @@ void cmd_msgs(char *cmdbuf)
        else
                mode = MSGS_ALL;
 
-       if ( (mode == MSGS_SEARCH) && (!config.c_enable_fulltext) ) {
+       if ( (mode == MSGS_SEARCH) && (!CtdlGetConfigInt("c_enable_fulltext")) ) {
                cprintf("%d Full text index is not enabled on this server.\n",
                        ERROR + CMD_NOT_SUPPORTED);
                return;
@@ -191,7 +190,7 @@ void cmd_msg0(char *cmdbuf)
        msgid = extract_long(cmdbuf, 0);
        headers_only = extract_int(cmdbuf, 1);
 
-       CtdlOutputMsg(msgid, MT_CITADEL, headers_only, 1, 0, NULL, 0, NULL, NULL);
+       CtdlOutputMsg(msgid, MT_CITADEL, headers_only, 1, 0, NULL, 0, NULL, NULL, NULL);
        return;
 }
 
@@ -207,7 +206,7 @@ void cmd_msg2(char *cmdbuf)
        msgid = extract_long(cmdbuf, 0);
        headers_only = extract_int(cmdbuf, 1);
 
-       CtdlOutputMsg(msgid, MT_RFC822, headers_only, 1, 1, NULL, 0, NULL, NULL);
+       CtdlOutputMsg(msgid, MT_RFC822, headers_only, 1, 1, NULL, 0, NULL, NULL, NULL);
 }
 
 
@@ -228,7 +227,7 @@ void cmd_msg3(char *cmdbuf)
        }
 
        msgnum = extract_long(cmdbuf, 0);
-       msg = CtdlFetchMessage(msgnum, 1);
+       msg = CtdlFetchMessage(msgnum, 1, 1);
        if (msg == NULL) {
                cprintf("%d Message %ld not found.\n", 
                        ERROR + MESSAGE_NOT_FOUND, msgnum);
@@ -261,7 +260,7 @@ void cmd_msg4(char *cmdbuf)
 
        msgid = extract_long(cmdbuf, 0);
        extract_token(section, cmdbuf, 1, '|', sizeof section);
-       CtdlOutputMsg(msgid, MT_MIME, 0, 1, 0, (section[0] ? section : NULL) , 0, NULL, NULL);
+       CtdlOutputMsg(msgid, MT_MIME, 0, 1, 0, (section[0] ? section : NULL) , 0, NULL, NULL, NULL);
 }
 
 
@@ -294,7 +293,7 @@ void cmd_opna(char *cmdbuf)
        extract_token(desired_section, cmdbuf, 1, '|', sizeof desired_section);
        safestrncpy(CC->download_desired_section, desired_section,
                sizeof CC->download_desired_section);
-       CtdlOutputMsg(msgid, MT_DOWNLOAD, 0, 1, 1, NULL, 0, NULL, NULL);
+       CtdlOutputMsg(msgid, MT_DOWNLOAD, 0, 1, 1, NULL, 0, NULL, NULL, NULL);
 }                      
 
 
@@ -310,7 +309,7 @@ void cmd_dlat(char *cmdbuf)
        extract_token(desired_section, cmdbuf, 1, '|', sizeof desired_section);
        safestrncpy(CC->download_desired_section, desired_section,
                sizeof CC->download_desired_section);
-       CtdlOutputMsg(msgid, MT_SPEW_SECTION, 0, 1, 1, NULL, 0, NULL, NULL);
+       CtdlOutputMsg(msgid, MT_SPEW_SECTION, 0, 1, 1, NULL, 0, NULL, NULL, NULL);
 }
 
 /*
@@ -599,7 +598,7 @@ void cmd_ent0(char *entargs)
        }
        free(all_recps);
 
-       if ((valid != NULL) && (valid->num_room == 1))
+       if ((valid != NULL) && (valid->num_room == 1) && !IsEmptyStr(valid->recp_orgroom))
        {
                /* posting into an ML room? set the envelope from 
                 * to the actual mail address so others get a valid