* Actually _enforce_ the max msg len limit
authorArt Cancro <ajc@citadel.org>
Wed, 1 Sep 1999 02:36:35 +0000 (02:36 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 1 Sep 1999 02:36:35 +0000 (02:36 +0000)
citadel/ChangeLog
citadel/config.c
citadel/msgbase.c
citadel/setup.c

index 276605069bb25df13898507febc86c0a8c8ddcb9..49516cd9dfea85697bd818e337fd361b1e17e309 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 1.358  1999/09/01 02:36:34  ajc
+* Actually _enforce_ the max msg len limit
+
 Revision 1.357  1999/09/01 01:51:48  ajc
 * Added the ability to handle embedded URL's from the text client
 
@@ -1217,4 +1220,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index 87f4f49f3dafd26fb3f7aa46aaed283457dbc39c..ed8fe1dc0d40475ef8f1622f45aba7de444048ce 100644 (file)
@@ -54,6 +54,7 @@ void get_config(void) {
                exit(1);
        }
        fclose(cfp);
+
        if (config.c_setup_level != REV_LEVEL) {
                fprintf(stderr, "config: Your data files are out of date.  ");
                fprintf(stderr, "Run setup to update them.\n");
@@ -66,6 +67,15 @@ void get_config(void) {
                        (config.c_setup_level % 100));
                exit(1);
        }
+
+        /* Default maximum message length is 'unlimited' (max int)
+         * and the minimum is 8192
+         */
+        if (config.c_maxmsglen <= 0)
+                config.c_maxmsglen = INT_MAX;
+        if (config.c_maxmsglen < 8192)
+                config.c_maxmsglen = 8192;
+               
 }
 
 
index 6625698a800ee7dae54dd8c6107ab7cf5b0c4537..2e8ea9feb43e6b3c867d346389f156e1110b8abf 100644 (file)
@@ -1233,30 +1233,34 @@ void aide_message(char *text)
        fclose(fp);
        save_message(CC->temp, "", AIDEROOM, MES_LOCAL, 1);
        syslog(LOG_NOTICE, text);
-}                              /*
+}
 
-                                * Build a binary message to be saved on disk.
-                                */ void make_message(
-                                                         char *filename,       /* temporary file name */
-                                                struct usersupp *author,       /* author's usersupp structure */
-                                                        char *recipient,       /* NULL if it's not mail */
-                                                            char *room,        /* room where it's going */
-                                                            int type,  /* see MES_ types in header file */
-                                                            int net_type,      /* see MES_ types in header file */
-                                                        int format_type,       /* local or remote (see citadel.h) */
-                                                        char *fake_name)
-{                              /* who we're masquerading as */
+
+/*
+ * Build a binary message to be saved on disk.
+ */
+
+void make_message(
+       char *filename,                 /* temporary file name */
+       struct usersupp *author,        /* author's usersupp structure */
+       char *recipient,                /* NULL if it's not mail */
+       char *room,                     /* room where it's going */
+       int type,                       /* see MES_ types in header file */
+       int net_type,                   /* see MES_ types in header file */
+       int format_type,                /* local or remote (see citadel.h) */
+       char *fake_name)                /* who we're masquerading as */
+{
 
        FILE *fp;
        int a;
        time_t now;
        char dest_node[32];
        char buf[256];
+       size_t msglen = 0;
 
        /* Don't confuse the poor folks if it's not routed mail. */
        strcpy(dest_node, "");
 
-
        /* If net_type is MES_BINARY, split out the destination node. */
        if (net_type == MES_BINARY) {
                strcpy(dest_node, NODENAME);
@@ -1267,9 +1271,11 @@ void aide_message(char *text)
                        }
                }
        }
+
        /* if net_type is MES_INTERNET, set the dest node to 'internet' */ if (net_type == MES_INTERNET) {
                strcpy(dest_node, "internet");
        }
+
        while (isspace(recipient[strlen(recipient) - 1]))
                recipient[strlen(recipient) - 1] = 0;
 
@@ -1280,6 +1286,7 @@ void aide_message(char *text)
        putc(format_type, fp);  /* Formatted or unformatted */
        fprintf(fp, "Pcit%ld%c", author->usernum, 0);   /* path */
        fprintf(fp, "T%ld%c", (long) now, 0);   /* date/time */
+
        if (fake_name[0])
                fprintf(fp, "A%s%c", fake_name, 0);
        else
@@ -1302,8 +1309,14 @@ void aide_message(char *text)
        putc('M', fp);
 
        while (client_gets(buf), strcmp(buf, "000")) {
-               fprintf(fp, "%s\n", buf);
+               if (msglen < config.c_maxmsglen) 
+                       fprintf(fp, "%s\n", buf);
+               else
+                       lprintf(7, "Message exceeded %d byte limit\n",
+                               config.c_maxmsglen);
+               msglen = msglen + strlen(buf) + 1;
        }
+
        putc(0, fp);
        fclose(fp);
 }
index 5632262b32ac44d63f189839860f44b9c9159fa7..d5eaf39c3381694c8e694b6d1d3f6868354dfd1b 100644 (file)
@@ -900,15 +900,6 @@ int main(int argc, char *argv[])
        }
 
 
-       /* Default maximum message length is 'unlimited' (max int)
-        * and the minimum is 8192
-        */
-       if (config.c_maxmsglen <= 0)
-               config.c_maxmsglen = INT_MAX;
-       if (config.c_maxmsglen < 8192)
-               config.c_maxmsglen = 8192;
-
-
        /* Go through a series of dialogs prompting for config info */
        for (curr = 1; curr <= MAXSETUP; ++curr) {
                edit_value(curr);