From 7fb1a3106f5e1ac313406cfbc73d6d2217418ea0 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 16 Aug 2002 20:50:28 +0000 Subject: [PATCH] Fixed ticfile crash thanks to BG garbage --- ChangeLog | 3 +++ mbfido/Makefile | 2 +- mbfido/areamgr.c | 16 +++++++++------- mbfido/filemgr.c | 34 +++++++++++++++++++--------------- mbfido/mgrutil.h | 7 +++++++ mbfido/notify.c | 5 +++-- mbfido/ptic.c | 6 +++++- mbfido/tic.c | 4 ++-- 8 files changed, 49 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9da5e10..b2df0a9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -51,6 +51,9 @@ v0.35.03 06-Jul-2002 Removed debug logline with extract of FILE_ID.DIZ. When a file is imported with a name that is already present, the existing filerecord is updated and not replaced. + There are people using M$ wordprocessors to create TIC files, + there is now better filtering to get that garbage out of the + received tic files. We will forward plain ascii of course. newuser: Check for Unix accounts is now case sensitive. diff --git a/mbfido/Makefile b/mbfido/Makefile index d9593ec7..5090dc67 100644 --- a/mbfido/Makefile +++ b/mbfido/Makefile @@ -186,7 +186,7 @@ filemgr.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/u hash.o: ../config.h ../lib/libs.h ../lib/memwatch.h hash.h lhash.h mbaff.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h announce.h filefind.h mbaff.h mbseq.o: ../config.h ../lib/libs.h ../lib/memwatch.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/memwatch.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 notify.h +notify.o: ../config.h ../lib/libs.h ../lib/memwatch.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/memwatch.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 scannews.o: ../config.h ../lib/libs.h ../lib/memwatch.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/memwatch.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 diff --git a/mbfido/areamgr.c b/mbfido/areamgr.c index b36f6fe2..deaa0637 100644 --- a/mbfido/areamgr.c +++ b/mbfido/areamgr.c @@ -51,10 +51,6 @@ #include "createm.h" #include "areamgr.h" -#define LIST_LIST 0 -#define LIST_NOTIFY 1 -#define LIST_QUERY 2 -#define LIST_UNLINK 3 @@ -97,7 +93,10 @@ void A_Help(faddr *t, char *replyid) if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject , replyid)) != NULL) { if ((fi = OpenMacro("areamgr.help", nodes.Language, FALSE)) != NULL ) { ta = bestaka_s(t); - MacroVars("sAYP", "ssss", nodes.Sysop, "Areamgr", ascfnode(ta, 0xf), nodes.Apasswd ); + MacroVars("s", "s", nodes.Sysop); + MacroVars("A", "s", (char *)"Areamgr"); + MacroVars("Y", "s", ascfnode(ta, 0xff)); + MacroVars("P", "s", nodes.Apasswd); tidy_faddr(ta); MacroRead(fi, fp); fclose(fi); @@ -136,7 +135,10 @@ void A_List(faddr *t, char *replyid, int Notify) subject = calloc(255, sizeof(char)); f = bestaka_s(t); - MacroVars("sKyY", "sdss", nodes.Sysop, Notify, ascfnode(t, 0xff), ascfnode(f, 0xf)); + MacroVars("s", "s", nodes.Sysop); + MacroVars("K", "d", Notify); + MacroVars("y", "s", ascfnode(t, 0xff)); + MacroVars("Y", "s", ascfnode(f, 0xff)); switch (Notify) { case LIST_NOTIFY: Syslog('+', "AreaMgr: Notify to %s", ascfnode(t, 0xff)); @@ -1140,7 +1142,7 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla A_Query(f, replyid); if (a_list) - A_List(f, replyid, FALSE); + A_List(f, replyid, LIST_LIST); if (a_flow) A_Flow(f, replyid, FALSE); diff --git a/mbfido/filemgr.c b/mbfido/filemgr.c index d4b33287..d080982d 100644 --- a/mbfido/filemgr.c +++ b/mbfido/filemgr.c @@ -50,10 +50,6 @@ #include "createf.h" #include "filemgr.h" -#define LIST_LIST 0 -#define LIST_NOTIFY 1 -#define LIST_QUERY 2 -#define LIST_UNLINK 3 /* @@ -90,7 +86,10 @@ void F_Help(faddr *t, char *replyid) if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid)) != NULL) { if ((fi = OpenMacro("filemgr.help", nodes.Language, FALSE)) != NULL ){ - MacroVars("sAYP", "ssss", nodes.Sysop, (char *)"Filemgr", ascfnode(bestaka_s(t), 0xf), nodes.Fpasswd ); + MacroVars("s", "s", nodes.Sysop); + MacroVars("A", "s", (char *)"Filemgr"); + MacroVars("Y", "s", ascfnode(bestaka_s(t), 0xf)); + MacroVars("P", "s", nodes.Fpasswd); MacroRead(fi, fp); MacroClear(); fclose(fi); @@ -125,7 +124,10 @@ void F_List(faddr *t, char *replyid, int Notify) subject = calloc(255, sizeof(char)); f = bestaka_s(t); - MacroVars("sKyY", "sdss", nodes.Sysop, Notify, ascfnode(t, 0xff), ascfnode(f, 0xf)); + MacroVars("s", "s", nodes.Sysop); + MacroVars("K", "d", Notify); + MacroVars("y", "s", ascfnode(t, 0xff)); + MacroVars("Y", "s", ascfnode(f, 0xff)); switch (Notify) { case LIST_NOTIFY: Syslog('+', "FileMgr: Notify to %s", ascfnode(t, 0xff)); @@ -207,7 +209,9 @@ void F_List(faddr *t, char *replyid, int Notify) if ((!strcmp(fgroup.Name, Group)) && (g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) { SubTot = 0; - MacroVars("GJI", "sss",fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka) ); + MacroVars("G", "s", fgroup.Name); + MacroVars("J", "s", fgroup.Comment); + MacroVars("I", "s", aka2str(fgroup.UseAka)); fsetpos(fi,&fileptr); MacroRead(fi, qp); fgetpos(fi,&fileptr1); @@ -236,13 +240,13 @@ void F_List(faddr *t, char *replyid, int Notify) if ( (Notify == LIST_LIST) || (Notify == LIST_NOTIFY) || ((Notify == LIST_QUERY) && ((Stat[0]=='S') || (Stat[1]=='R'))) - || ((Notify >= LIST_UNLINK) && ((Stat[0]!='S') && (Stat[1]!='R')))){ - MacroVars("XDEsrp", "sssddd", - Stat, tic.Name, tic.Comment, - (Stat[0] == 'S'), - (Stat[1] == 'R'), - (Stat[2] == 'P') - ); + || ((Notify >= LIST_UNLINK) && ((Stat[0]!='S') && (Stat[1]!='R')))) { + MacroVars("X", "s", Stat); + MacroVars("D", "s", tic.Name); + MacroVars("E", "s", tic.Comment); + MacroVars("s", "d", (Stat[0] == 'S')); + MacroVars("r", "d", (Stat[1] == 'R')); + MacroVars("p", "d", (Stat[2] == 'P')); fsetpos(fi,&fileptr1); MacroRead(fi, qp); fgetpos(fi,&fileptr2); @@ -964,7 +968,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla F_Query(f, replyid); if (f_list) - F_List(f, replyid, FALSE); + F_List(f, replyid, LIST_LIST); if (f_unlnk) F_Unlinked(f, replyid); diff --git a/mbfido/mgrutil.h b/mbfido/mgrutil.h index 93cd547e..31ba595b 100644 --- a/mbfido/mgrutil.h +++ b/mbfido/mgrutil.h @@ -4,6 +4,13 @@ #define _MGRUTIL_H +#define LIST_LIST 0 +#define LIST_NOTIFY 1 +#define LIST_QUERY 2 +#define LIST_UNLINK 3 + + + /* * Linked list for atea areas create */ diff --git a/mbfido/notify.c b/mbfido/notify.c index 103915d2..4e3b6a53 100644 --- a/mbfido/notify.c +++ b/mbfido/notify.c @@ -42,6 +42,7 @@ #include "filemgr.h" #include "areamgr.h" #include "sendmail.h" +#include "mgrutil.h" #include "notify.h" @@ -147,8 +148,8 @@ int Notify(char *Options) F_Status(Tmp, NULL); A_Status(Tmp, NULL); } - F_List(Tmp, NULL, TRUE); - A_List(Tmp, NULL, TRUE); + F_List(Tmp, NULL, LIST_NOTIFY); + A_List(Tmp, NULL, LIST_NOTIFY); A_Flow(Tmp, NULL, TRUE); tidy_faddr(Tmp); notify++; diff --git a/mbfido/ptic.c b/mbfido/ptic.c index 34eb1ae0..2a911d8c 100644 --- a/mbfido/ptic.c +++ b/mbfido/ptic.c @@ -603,8 +603,12 @@ int ProcessTic(fa_list *sbl) strcpy(TDesc, TIC.TicIn.Desc); while (strlen(TDesc) > 48) { j = 48; - while (TDesc[j] != ' ') + while ((TDesc[j] != ' ') && (j > 0)) j--; + if (j == 0) { + Syslog('f', "Panic, no spaces"); + j = 47; + } strncpy(TIC.File_Id[TIC.File_Id_Ct], TDesc, j); Syslog('f', "%2d/%2d: \"%s\"", TIC.File_Id_Ct, j, TIC.File_Id[TIC.File_Id_Ct]); TIC.File_Id_Ct++; diff --git a/mbfido/tic.c b/mbfido/tic.c index a0b7cec4..7c600288 100644 --- a/mbfido/tic.c +++ b/mbfido/tic.c @@ -209,8 +209,8 @@ int LoadTic(char *inb, char *tfn) Temp[0] = '\0'; j = 0; for (i = 0; i < strlen(Buf); i++) - if (isprint(Buf[i])) { - Temp[j] = Buf[i]; + if (isprint(Buf[i] & 0x7f)) { + Temp[j] = Buf[i] & 0x7f; j++; } Temp[j] = '\0';