From 8c2ce9da3bfccd98e73f7748820cef6885d9586f Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Tue, 2 Sep 2003 20:25:42 +0000 Subject: [PATCH] Fixed buffer overflow with too long newsheader --- ChangeLog | 10 ++++++++++ lib/msg.c | 4 ++-- lib/msg.h | 6 +++++- mbcico/Makefile | 4 ++-- mbcico/respfreq.c | 5 +++-- mbfido/Makefile | 4 ++-- mbfido/areamgr.c | 6 +++--- mbfido/bounce.c | 6 +++--- mbfido/filemgr.c | 6 +++--- mbfido/ping.c | 6 +++--- mbfido/postecho.c | 14 +++++++------- mbfido/postemail.c | 3 ++- mbfido/postnetmail.c | 9 +++++---- mbfido/rfc2ftn.c | 3 ++- mbfido/storeecho.c | 4 ++-- mbfido/storenet.c | 4 ++-- mbfido/tosspkt.c | 6 +++--- mbsebbs/email.c | 4 ++-- mbsebbs/fsedit.h | 2 +- mbsebbs/mail.c | 4 ++-- mbsebbs/offline.c | 2 +- 21 files changed, 65 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79bf5d69..345327a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,6 +32,10 @@ v0.37.6 10-Aug-2003 ftscprod.007 Changed the website address in several sources. + libmsgbase.a: + Resolved a buffer overflow problem with kludges larger then + 512 bytes. + nodelist.a: Removed some of the debug logging. @@ -55,6 +59,12 @@ v0.37.6 10-Aug-2003 session password. Also improved the password check. The product code was not entered in the FTS-0001 packet headers. + mbfido: + The rfc to ftn gate now drops the headerlines starting with + X-Spam- because they are only filled with advertisents and are + very large (upto 1200 bytes which is somewhat larger for a + fidonet kludge). + mbsetup: In the nodes setup a switch is added to fallback to the wrong binkp escape method. diff --git a/lib/msg.c b/lib/msg.c index 744d03d8..c245d80e 100644 --- a/lib/msg.c +++ b/lib/msg.c @@ -310,8 +310,8 @@ void Msg_Write(FILE *fp) char *Buf; int i; - Buf = calloc(2049, sizeof(char)); - while ((fgets(Buf, 2048, fp)) != NULL) { + Buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); + while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) { for (i = 0; i < strlen(Buf); i++) { if (*(Buf + i) == '\0') diff --git a/lib/msg.h b/lib/msg.h index 4d342cbc..4be44234 100644 --- a/lib/msg.h +++ b/lib/msg.h @@ -3,7 +3,11 @@ #ifndef _MSG_H #define _MSG_H -#define MAX_LINE_LENGTH 512 +/* + * Global maximum line length for all files that do something with + * message text. + */ +#define MAX_LINE_LENGTH 2048 /* diff --git a/mbcico/Makefile b/mbcico/Makefile index 2ef33099..df626428 100644 --- a/mbcico/Makefile +++ b/mbcico/Makefile @@ -105,13 +105,13 @@ dial.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records dietifna.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ttyio.h session.h emsi.h dietifna.h respfreq.h filelist.h xmrecv.h xmsend.h emsidat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h emsi.h session.h lutil.h config.h emsidat.h filetime.h filelist.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/nodelist.h config.h session.h filelist.h -openfile.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h config.h lutil.h openfile.h +openfile.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h ../lib/users.h ../lib/records.h config.h lutil.h openfile.h openport.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ulock.h ttyio.h openport.h opentcp.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h session.h ttyio.h openport.h opentcp.h rdoptions.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h session.h config.h yoohoo.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/nodelist.h ../lib/dbnode.h ../lib/mberrors.h statetbl.h ttyio.h session.h config.h emsi.h hydra.h rdoptions.h wazoo.h dietifna.h yoohoo.h inbound.h recvbark.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ttyio.h session.h statetbl.h recvbark.h respfreq.h filelist.h -respfreq.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h session.h lutil.h config.h atoul.h respfreq.h filelist.h +respfreq.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/msg.h session.h lutil.h config.h atoul.h respfreq.h filelist.h sendbark.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ttyio.h session.h statetbl.h sendbark.h xmrecv.h tcp.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ttyio.h session.h statetbl.h config.h emsi.h respfreq.h filelist.h tcpproto.h tcp.h tcpproto.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/mberrors.h ttyio.h session.h config.h emsi.h lutil.h openfile.h filelist.h tcpproto.h diff --git a/mbcico/respfreq.c b/mbcico/respfreq.c index e2d15863..c01a9740 100644 --- a/mbcico/respfreq.c +++ b/mbcico/respfreq.c @@ -36,6 +36,7 @@ #include "../lib/common.h" #include "../lib/nodelist.h" #include "../lib/clcomm.h" +#include "../lib/msg.h" #include "session.h" #include "lutil.h" #include "config.h" @@ -538,8 +539,8 @@ file_list *respmagic(char *cmd) /* must free(cmd) before exit */ if ((ft = fopen(tmpfn, "r")) == NULL) { WriteError("$Can't open %s", tmpfn); } else { - buf = calloc(2049, sizeof(char)); - while ((fgets(buf, 2048, ft)) != NULL) { + buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); + while ((fgets(buf, MAX_LINE_LENGTH, ft)) != NULL) { for (i = 0; i < strlen(buf); i++) { if (*(buf + i) == '\0') break; diff --git a/mbfido/Makefile b/mbfido/Makefile index 06e428e3..349d5185 100644 --- a/mbfido/Makefile +++ b/mbfido/Makefile @@ -177,7 +177,7 @@ grlist.o: ../config.h ../lib/libs.h ../lib/clcomm.h grlist.h maketags.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h maketags.h mbmsg.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/dbcfg.h ../lib/mberrors.h post.h mbmsg.h newspost.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h newspost.h -postemail.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/dbuser.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h postemail.h +postemail.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/dbuser.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/msg.h postemail.h scan.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/msg.h ../lib/clcomm.h ../lib/msgtext.h ../lib/dbnode.h ../lib/dbmsgs.h addpkt.h tracker.h ftn2rfc.h rfc2ftn.h rollover.h postemail.h scan.h toberep.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h tic.h toberep.h atoul.o: ../config.h ../lib/libs.h atoul.h @@ -186,7 +186,7 @@ hash.o: ../config.h ../lib/libs.h hash.h lhash.h mbaff.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/mberrors.h announce.h filefind.h mbaff.h mbseq.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbseq.h notify.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbnode.h filemgr.h areamgr.h sendmail.h mgrutil.h notify.h -postnetmail.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/common.h ../lib/records.h ../lib/dbcfg.h ../lib/dbuser.h ../lib/dbnode.h ../lib/dbftn.h ../lib/clcomm.h tracker.h addpkt.h storenet.h ftn2rfc.h areamgr.h filemgr.h ping.h bounce.h postemail.h +postnetmail.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/common.h ../lib/records.h ../lib/dbcfg.h ../lib/dbuser.h ../lib/dbnode.h ../lib/dbftn.h ../lib/clcomm.h ../lib/msg.h tracker.h addpkt.h storenet.h ftn2rfc.h areamgr.h filemgr.h ping.h bounce.h postemail.h scannews.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h rollover.h storeecho.h rfc2ftn.h scannews.h tosspkt.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h tosspkt.h postnetmail.h postecho.h rollover.h createm.h mbfkill.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/mberrors.h mbfkill.h mbfutil.h diff --git a/mbfido/areamgr.c b/mbfido/areamgr.c index 32ca193f..ee6af1a7 100644 --- a/mbfido/areamgr.c +++ b/mbfido/areamgr.c @@ -1054,10 +1054,10 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla return FALSE; } - Buf = calloc(2049, sizeof(char)); + Buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); rewind(fp); - while ((fgets(Buf, 2048, fp)) != NULL) { + while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) { /* * Make sure we have the nodes record loaded @@ -1150,7 +1150,7 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla fprintf(np, "\r"); fseek(tmp, 0, SEEK_SET); - while ((fgets(Buf, 2048, tmp)) != NULL) { + while ((fgets(Buf, MAX_LINE_LENGTH, tmp)) != NULL) { while ((Buf[strlen(Buf) - 1]=='\n') || (Buf[strlen(Buf) - 1]=='\r')) { Buf[strlen(Buf) - 1] = '\0'; } diff --git a/mbfido/bounce.c b/mbfido/bounce.c index 6ffe8830..30bb9e39 100644 --- a/mbfido/bounce.c +++ b/mbfido/bounce.c @@ -79,7 +79,7 @@ int Bounce(faddr *f, faddr *t, FILE *fp, char *reason) f->domain = xstrcpy(fidonet.domain); Syslog('+', "Bounce msg from %s", ascfnode(f, 0xff)); - Buf = calloc(2049, sizeof(char)); + Buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); rewind(fp); np = tmpfile(); @@ -100,7 +100,7 @@ int Bounce(faddr *f, faddr *t, FILE *fp, char *reason) * Add MSGID, REPLY and PID */ fprintf(np, "\001MSGID: %s %08lx\r", ascfnode(from, 0x1f), sequencer()); - while ((fgets(Buf, 2048, fp)) != NULL) { + while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(Buf); if (strncmp(Buf, "\001MSGID:", 7) == 0) { fprintf(np, "\001REPLY:%s\r", Buf+7); @@ -115,7 +115,7 @@ int Bounce(faddr *f, faddr *t, FILE *fp, char *reason) fprintf(np, "======================================================================\r"); rewind(fp); - while ((fgets(Buf, 2048, fp)) != NULL) { + while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(Buf); if (Buf[0] == '\001') { fprintf(np, "^a"); diff --git a/mbfido/filemgr.c b/mbfido/filemgr.c index 49c0e7e3..8470f4b2 100644 --- a/mbfido/filemgr.c +++ b/mbfido/filemgr.c @@ -872,10 +872,10 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla return FALSE; } - Buf = calloc(2049, sizeof(char)); + Buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); rewind(fp); - while ((fgets(Buf, 2048, fp)) != NULL) { + while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) { /* * Make sure we refresh the nodes record. @@ -962,7 +962,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla fprintf(np, "\r"); fseek(tmp, 0, SEEK_SET); - while ((fgets(Buf, 2048, tmp)) != NULL) { + while ((fgets(Buf, MAX_LINE_LENGTH, tmp)) != NULL) { while ((Buf[strlen(Buf) - 1]=='\n') || (Buf[strlen(Buf) - 1]=='\r')) { Buf[strlen(Buf) - 1] = '\0'; } diff --git a/mbfido/ping.c b/mbfido/ping.c index 42b51097..158d1584 100644 --- a/mbfido/ping.c +++ b/mbfido/ping.c @@ -79,7 +79,7 @@ int Ping(faddr *f, faddr *t, FILE *fp, int intransit) f->domain = xstrcpy(fidonet.domain); Syslog('+', "%s ping msg from %s", intransit ? "Intransit":"Final", ascfnode(f, 0xff)); - Buf = calloc(2049, sizeof(char)); + Buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); rewind(fp); np = tmpfile(); @@ -104,7 +104,7 @@ int Ping(faddr *f, faddr *t, FILE *fp, int intransit) * Add MSGID, REPLY and PID */ fprintf(np, "\001MSGID: %s %08lx\r", ascfnode(from, 0x1f), sequencer()); - while ((fgets(Buf, 2048, fp)) != NULL) { + while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(Buf); if (strncmp(Buf, "\001MSGID:", 7) == 0) { fprintf(np, "\001REPLY:%s\r", Buf+7); @@ -124,7 +124,7 @@ int Ping(faddr *f, faddr *t, FILE *fp, int intransit) fprintf(np, "======================================================================\r"); rewind(fp); - while ((fgets(Buf, 2048, fp)) != NULL) { + while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(Buf); if (strncmp(Buf, "\1Via", 4) == 0) { fprintf(np, "%s\r", Buf+1); diff --git a/mbfido/postecho.c b/mbfido/postecho.c index 7b7241bb..bf7a0c66 100644 --- a/mbfido/postecho.c +++ b/mbfido/postecho.c @@ -112,9 +112,9 @@ int EchoOut(fidoaddr aka, char *toname, char *fromname, char *subj, FILE *fp, in } rewind(fp); - buf = calloc(2049, sizeof(char)); + buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); - while ((fgets(buf, 2048, fp)) != NULL) { + while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(buf); fprintf(qp, "%s\r", buf); } @@ -207,10 +207,10 @@ int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t m /* * Read the message for kludges we need. */ - buf = calloc(2049, sizeof(char)); + buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); First = TRUE; rewind(fp); - while ((fgets(buf, 2048, fp)) != NULL) { + while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(buf); @@ -264,7 +264,7 @@ int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t m * dupecheck. Redy Rodriguez. */ rewind(fp); - while ((fgets(buf, 2048, fp)) != NULL) { + while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(buf); if (strncmp(buf, "---", 3) == 0) break; @@ -396,7 +396,7 @@ int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t m rewind(fp); if ((nfp = tmpfile()) == NULL) WriteError("$Unable to open tmpfile"); - while ((fgets(buf, 2048, fp)) != NULL) { + while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(buf); fprintf(nfp, "%s", buf); /* @@ -502,7 +502,7 @@ int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t m if (strlen(msgs.Newsgroup) && tonews) { rewind(nfp); qp = tmpfile(); - while ((fgets(buf, 2048, nfp)) != NULL) { + while ((fgets(buf, MAX_LINE_LENGTH, nfp)) != NULL) { Striplf(buf); if (kludges && (buf[0] != '\001') && strncmp(buf, "AREA:", 5)) { kludges = FALSE; diff --git a/mbfido/postemail.c b/mbfido/postemail.c index 44ca2695..3e723ebb 100644 --- a/mbfido/postemail.c +++ b/mbfido/postemail.c @@ -37,6 +37,7 @@ #include "../lib/common.h" #include "../lib/clcomm.h" #include "../lib/mbinet.h" +#include "../lib/msg.h" #include "postemail.h" @@ -90,7 +91,7 @@ int postemail(FILE *fp, char *MailFrom, char *MailTo) return 2; } - temp = calloc(2048, sizeof(char)); + temp = calloc(MAX_LINE_LENGTH +1, sizeof(char)); sprintf(temp, "MAIL FROM:<%s>\r\n", MailFrom); if (smtp_cmd(temp, 250)) { WriteError("SMTP: refused FROM <%s>", MailFrom); diff --git a/mbfido/postnetmail.c b/mbfido/postnetmail.c index 09e85b98..f22200db 100644 --- a/mbfido/postnetmail.c +++ b/mbfido/postnetmail.c @@ -39,6 +39,7 @@ #include "../lib/dbnode.h" #include "../lib/dbftn.h" #include "../lib/clcomm.h" +#include "../lib/msg.h" #include "tracker.h" #include "addpkt.h" #include "storenet.h" @@ -89,9 +90,9 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t /* * Extract MSGID and REPLY kludges from this netmail. */ - buf = calloc(2049, sizeof(char)); + buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); rewind(fp); - while ((fgets(buf, 2048, fp)) != NULL) { + while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(buf); Syslogp('M', printable(buf, 0)); if (!strncmp(buf, "\001MSGID: ", 8)) { @@ -432,8 +433,8 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t * Copy all text including kludges, when * finished, insert our ^aVia line. */ - buf = calloc(2048, sizeof(char)); - while ((fgets(buf, 2048, fp)) != NULL) + buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); + while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) fprintf(net, "%s\r", buf); now = time(NULL); diff --git a/mbfido/rfc2ftn.c b/mbfido/rfc2ftn.c index 31b9f8bf..46f6f329 100644 --- a/mbfido/rfc2ftn.c +++ b/mbfido/rfc2ftn.c @@ -76,7 +76,7 @@ extern int do_learn; extern int news_in; extern int email_in; extern char *replyaddr; - +extern int most_debug; /* @@ -835,6 +835,7 @@ int needputrfc(rfcmsg *msg, int newsmode) if (!strcasecmp(msg->key,"Precedence")) return 0; if (!strcasecmp(msg->key,"X-Face")) return 0; if (!strcasecmp(msg->key,"X-Accept-Language")) return 0; + if (!strncasecmp(msg->key,"X-Spam-", 7)) return 0; /*if (!strcasecmp(msg->key,"")) return ;*/ return 1; } diff --git a/mbfido/storeecho.c b/mbfido/storeecho.c index 00c3ca96..6de11239 100644 --- a/mbfido/storeecho.c +++ b/mbfido/storeecho.c @@ -152,10 +152,10 @@ int storeecho(faddr *f, faddr *t, time_t mdate, int flags, char *subj, char *msg * If not a bad or dupe message, eat the first * line (AREA:tag). */ - buf = calloc(2049, sizeof(char)); + buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); rewind(fp); if (!dupe && !bad) - fgets(buf , 2048, fp); + fgets(buf , MAX_LINE_LENGTH, fp); Msg_Write(fp); Msg_AddMsg(); Msg_UnLock(); diff --git a/mbfido/storenet.c b/mbfido/storenet.c index 3d3ceedb..c3fa53ff 100644 --- a/mbfido/storenet.c +++ b/mbfido/storenet.c @@ -145,8 +145,8 @@ int storenet(faddr *f, faddr *t, time_t mdate, int flags, char *Subj, char *msgi * Check if this is an empty netmail */ rewind(fp); - Buf = calloc(2049, sizeof(char)); - while ((fgets(Buf, 2048, fp)) != NULL) { + Buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); + while ((fgets(Buf, MAX_LINE_LENGTH, fp)) != NULL) { for (i = 0; i < strlen(Buf); i++) { if (*(Buf + i) == '\0') diff --git a/mbfido/tosspkt.c b/mbfido/tosspkt.c index ac55604d..0967d8c6 100644 --- a/mbfido/tosspkt.c +++ b/mbfido/tosspkt.c @@ -174,7 +174,7 @@ int importmsg(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t Known = TRUE; } - buf = calloc(2049, sizeof(char)); + buf = calloc(MAX_LINE_LENGTH +1, sizeof(char)); marea = NULL; /* @@ -183,7 +183,7 @@ int importmsg(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t rewind(fp); FirstLine = TRUE; - while ((fgets(buf, 2048, fp)) != NULL) { + while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) { Striplf(buf); @@ -320,7 +320,7 @@ int TossPkt(char *fn) */ int getmessage(FILE *pkt, faddr *p_from, faddr *p_to) { - char buf[2048], *orig = NULL, *p, *l, *r, *subj = NULL; + char buf[MAX_LINE_LENGTH +1], *orig = NULL, *p, *l, *r, *subj = NULL; int tmp, rc, maxrc = 0, result, flags, cost; static faddr f, t; faddr *o; diff --git a/mbsebbs/email.c b/mbsebbs/email.c index a1d04006..485d1c6a 100644 --- a/mbsebbs/email.c +++ b/mbsebbs/email.c @@ -692,7 +692,7 @@ void Reply_Email(int IsReply) sLine(); for (i = 0; i < (TEXTBUFSIZE + 1); i++) - Message[i] = (char *) calloc(81, sizeof(char)); + Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char)); Line = 1; Msg_New(); @@ -821,7 +821,7 @@ void Write_Email(void) clear(); for (i = 0; i < (TEXTBUFSIZE + 1); i++) - Message[i] = (char *) calloc(81, sizeof(char)); + Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char)); Line = 1; Msg_New(); diff --git a/mbsebbs/fsedit.h b/mbsebbs/fsedit.h index 9600e3ab..22d7549d 100644 --- a/mbsebbs/fsedit.h +++ b/mbsebbs/fsedit.h @@ -7,7 +7,7 @@ int Fs_Edit(void); /* The fullscreen message editor */ extern int Line; /* Number of lines + 1 */ -extern char *Message[]; /* TEXTBUFSIZE lines of 80 chars */ +extern char *Message[]; /* TEXTBUFSIZE lines of MAX_LINE_LENGTH chars */ int Row; /* Current row on screen */ int Col; /* Current column in text and on screen */ diff --git a/mbsebbs/mail.c b/mbsebbs/mail.c index 8f5683e2..0ff907a6 100644 --- a/mbsebbs/mail.c +++ b/mbsebbs/mail.c @@ -410,7 +410,7 @@ void Post_Msg() return; for (i = 0; i < (TEXTBUFSIZE + 1); i++) - Message[i] = (char *) calloc(81, sizeof(char)); + Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char)); Line = 1; Msg_New(); @@ -1321,7 +1321,7 @@ void Reply_Msg(int IsReply) sLine(); for (i = 0; i < (TEXTBUFSIZE + 1); i++) - Message[i] = (char *) calloc(81, sizeof(char)); + Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char)); Msg_New(); strncpy(Msg.Replyid, msgid, 80); diff --git a/mbsebbs/offline.c b/mbsebbs/offline.c index aaa084a9..4b34aa2e 100644 --- a/mbsebbs/offline.c +++ b/mbsebbs/offline.c @@ -2280,7 +2280,7 @@ void QWK_Fetch() colour(LIGHTBLUE, BLACK); /* Processing BlueWave reply packet */ printf("%s\n", (char *)Language(459)); - temp = calloc(2048, sizeof(char)); + temp = calloc(PATH_MAX, sizeof(char)); otemp = calloc(PATH_MAX, sizeof(char)); nWidth = 78;