From 6b3aca987f93b9b93fb64d65eccbe7b2db24c744 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 12 May 2002 21:28:13 +0000 Subject: [PATCH] Small fixes for file announces --- mbfido/announce.c | 15 ++++++++++----- mbfido/msgutil.c | 12 +++++++----- mbfido/ptic.c | 13 +++++++------ mbsebbs/mbtoberep.c | 5 +++-- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/mbfido/announce.c b/mbfido/announce.c index bb140306..317f0961 100644 --- a/mbfido/announce.c +++ b/mbfido/announce.c @@ -293,6 +293,10 @@ long Report(gr_list *ta, long filepos) return 0; } + MacroVars("GJZ", "ssd", "", "", 0); + MacroVars("slbkdt", "ssddss", "", "", 0, 0, "", ""); + MacroVars("ABZ", "ddd", 0, 0, 0); + while (fread(&T_File, sizeof(T_File), 1, fp) == 1) { if ((!strcmp(T_File.Echo, ta->echo)) && (!strcmp(T_File.Group, ta->group))) break; @@ -322,7 +326,7 @@ long Report(gr_list *ta, long filepos) * Report one newfile, first line. */ fseek(fi, filepos1, SEEK_SET); - MacroVars("slbkdt", "ssddss", T_File.Name, T_File.LName, T_File.Size, T_File.SizeKb, " ", + MacroVars("slbkdt", "ssddss", T_File.Name, T_File.LName, T_File.Size, T_File.SizeKb, rfcdate(T_File.Fdate), To_Low(T_File.LDesc[0],newfiles.HiAscii)); Msg_Macro(fi); filepos2 = ftell(fi); @@ -335,8 +339,8 @@ long Report(gr_list *ta, long filepos) if (strlen(T_File.LDesc[i])) { Msg_Macro(fi); } else { - line = calloc(255, sizeof(char)); - while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {} + line = calloc(MAXSTR, sizeof(char)); + while ((fgets(line, MAXSTR-2, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {} free(line); } filepos3 = ftell(fi); @@ -397,7 +401,7 @@ int Announce() Uploads(); IsDoing("Announce files"); - temp = calloc(128, sizeof(char)); + temp = calloc(PATH_MAX, sizeof(char)); sprintf(temp, "%s/etc/toberep.data", getenv("MBSE_ROOT")); if ((fp = fopen(temp, "r")) == NULL) { Syslog('+', "No new files to announce"); @@ -470,10 +474,11 @@ int Announce() if ((filepos1 = StartMsg()) != -1) { filepos2 = 0; while (fread(&group, 13, 1, fp) == 1) { - for (tmp = fgr; tmp; tmp = tmp->next) + for (tmp = fgr; tmp; tmp = tmp->next) { if (!strcmp(tmp->group, group)) { filepos2 = Report(tmp, filepos1); } + } } FinishMsg(TRUE, filepos2); } diff --git a/mbfido/msgutil.c b/mbfido/msgutil.c index 719e9019..84938458 100644 --- a/mbfido/msgutil.c +++ b/mbfido/msgutil.c @@ -106,10 +106,11 @@ void Msg_Macro(FILE *fi) char *temp, *line; int res; - temp = calloc(256, sizeof(char)); - line = calloc(256, sizeof(char)); + temp = calloc(MAXSTR, sizeof(char)); + line = calloc(MAXSTR, sizeof(char)); + + while ((fgets(line, MAXSTR-2, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) { - while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) { /* * Skip comment lines */ @@ -121,7 +122,7 @@ void Msg_Macro(FILE *fi) */ MsgText_Add2((char *)""); } else { - strncpy(temp, ParseMacro(line,&res), 254); + strncpy(temp, ParseMacro(line,&res), MAXSTR-2); if (res) Syslog('!', "Macro error line: \"%s\"", line); /* @@ -160,6 +161,7 @@ long Msg_Top(char *template, int language, fidoaddr aka) if ((fp = fopen(temp, "r")) != NULL) { fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, fp); + MacroVars("pqrf", "dsss", 0, "", "", ""); while (fread(&ttyinfo, ttyinfohdr.recsize, 1, fp) == 1) { if (((ttyinfo.type == POTS) || (ttyinfo.type == ISDN)) && ttyinfo.available && strlen(ttyinfo.phone)) { MacroVars("pqrf", "dsss", ttyinfo.type, ttyinfo.phone, ttyinfo.speed, ttyinfo.flags); @@ -250,7 +252,7 @@ char *To_Low(char *inp, int High) int i; memset(&temp, 0, sizeof(temp)); - sprintf(temp, "%s", inp); + strncpy(temp, inp, 80); if (High) return temp; diff --git a/mbfido/ptic.c b/mbfido/ptic.c index 852ea901..bdee65e7 100644 --- a/mbfido/ptic.c +++ b/mbfido/ptic.c @@ -228,8 +228,8 @@ int ProcessTic(fa_list *sbl) } } - strcpy(T_File.Echo, tic.Name); - strcpy(T_File.Group, tic.Group); + strncpy(T_File.Echo, tic.Name, 20); + strncpy(T_File.Group, tic.Group, 12); TIC.KeepNum = tic.KeepLatest; Magic_Keepnum(); @@ -267,9 +267,9 @@ int ProcessTic(fa_list *sbl) * the group to that name. */ if (strlen(area.NewGroup)) - strcpy(T_File.Group, area.NewGroup); + strncpy(T_File.Group, area.NewGroup, 12); } - strcpy(T_File.Comment, tic.Comment); + strncpy(T_File.Comment, tic.Comment, 55); /* * Check if the destination area really exists, it may be that @@ -701,10 +701,11 @@ int ProcessTic(fa_list *sbl) Magic_UpDateAlias(); for (i = 0; i <= TIC.File_Id_Ct; i++) - strcpy(T_File.LDesc[i], TIC.File_Id[i]); + strncpy(T_File.LDesc[i], TIC.File_Id[i], 48); T_File.TotLdesc = TIC.File_Id_Ct; T_File.Announce = tic.Announce; - strcpy(T_File.Name, TIC.NewName); + strncpy(T_File.Name, TIC.NewName, 12); + strncpy(T_File.LName, TIC.NewName, 80); T_File.Fdate = TIC.FileDate; T_File.Cost = TIC.TicIn.Cost; Add_ToBeRep(); diff --git a/mbsebbs/mbtoberep.c b/mbsebbs/mbtoberep.c index c666231f..9136000c 100644 --- a/mbsebbs/mbtoberep.c +++ b/mbsebbs/mbtoberep.c @@ -67,8 +67,9 @@ int main(int argc, char **argv) printf("File echo %s\n", rep.Echo); printf("Comment %s\n", rep.Comment); printf("Group %s\n", rep.Group); - printf("File name %s\n", rep.Name); - printf("FIle size %lu\n", (long)(rep.Size)); + printf("Short name %s\n", rep.Name); + printf("Long name %s\n", rep.LName); + printf("File size %lu\n", (long)(rep.Size)); printf("File size Kb %lu\n", rep.SizeKb); printf("File date %s", ctime(&rep.Fdate)); printf("File CRC %s\n", rep.Crc);