From 48b2d0a3333ff4b62ed3d14f2e641c6089b4adc4 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 1 Sep 1999 02:36:35 +0000 Subject: [PATCH] * Actually _enforce_ the max msg len limit --- citadel/ChangeLog | 4 +++- citadel/config.c | 10 ++++++++++ citadel/msgbase.c | 41 +++++++++++++++++++++++++++-------------- citadel/setup.c | 9 --------- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 276605069..49516cd9d 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/config.c b/citadel/config.c index 87f4f49f3..ed8fe1dc0 100644 --- a/citadel/config.c +++ b/citadel/config.c @@ -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; + } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 6625698a8..2e8ea9feb 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -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); } diff --git a/citadel/setup.c b/citadel/setup.c index 5632262b3..d5eaf39c3 100644 --- a/citadel/setup.c +++ b/citadel/setup.c @@ -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); -- 2.39.2