diff --git a/mbsetup/m_marea.c b/mbsetup/m_marea.c index a11f9952..a4147f4a 100644 --- a/mbsetup/m_marea.c +++ b/mbsetup/m_marea.c @@ -61,7 +61,7 @@ int CountMsgarea(void) int count, i; struct _sysconnect syscon; - sprintf(ffile, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(ffile, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "a+")) != NULL) { Syslog('+', "Created new %s", ffile); @@ -74,10 +74,10 @@ int CountMsgarea(void) * Default first message area */ memset(&msgs, 0, sizeof(msgs)); - sprintf(msgs.Name, "Local users chat"); - sprintf(msgs.Base, "%s/var/mail/local/users", getenv("MBSE_ROOT")); - sprintf(msgs.QWKname, "LOC_USERS"); - sprintf(msgs.Group, "LOCAL"); + snprintf(msgs.Name, 41, "Local users chat"); + snprintf(msgs.Base, 65, "%s/var/mail/local/users", getenv("MBSE_ROOT")); + snprintf(msgs.QWKname, 21, "LOC_USERS"); + snprintf(msgs.Group, 13, "LOCAL"); msgs.Active = TRUE; msgs.Type = LOCALMAIL; msgs.MsgKinds = PUBLIC; @@ -101,10 +101,10 @@ int CountMsgarea(void) * Default message area for badmail */ memset(&msgs, 0, sizeof(msgs)); - sprintf(msgs.Name, "Bad mail"); - sprintf(msgs.Base, "%s/var/mail/badmail", getenv("MBSE_ROOT")); - sprintf(msgs.QWKname, "BADMAIL"); - sprintf(msgs.Group, "LOCAL"); + snprintf(msgs.Name, 41, "Bad mail"); + snprintf(msgs.Base, 65, "%s/var/mail/badmail", getenv("MBSE_ROOT")); + snprintf(msgs.QWKname, 21, "BADMAIL"); + snprintf(msgs.Group, 13, "LOCAL"); msgs.Active = TRUE; msgs.Type = LOCALMAIL; msgs.MsgKinds = PUBLIC; @@ -125,10 +125,10 @@ int CountMsgarea(void) * Default dupemail message area */ memset(&msgs, 0, sizeof(msgs)); - sprintf(msgs.Name, "Dupe mail"); - sprintf(msgs.Base, "%s/var/mail/dupemail", getenv("MBSE_ROOT")); - sprintf(msgs.QWKname, "DUPEMAIL"); - sprintf(msgs.Group, "LOCAL"); + snprintf(msgs.Name, 41, "Dupe mail"); + snprintf(msgs.Base, 65, "%s/var/mail/dupemail", getenv("MBSE_ROOT")); + snprintf(msgs.QWKname, 21, "DUPEMAIL"); + snprintf(msgs.Group, 13, "LOCAL"); msgs.Active = TRUE; msgs.Type = LOCALMAIL; msgs.MsgKinds = PUBLIC; @@ -186,15 +186,15 @@ int OpenMsgarea(void) * if they don't have a creation date. All new areas will get the * right date. */ - sprintf(fnin, "%s/etc/sysinfo.data", getenv("MBSE_ROOT")); + snprintf(fnin, PATH_MAX, "%s/etc/sysinfo.data", getenv("MBSE_ROOT")); if ((fin = fopen(fnin, "r"))) { fread(&SYSINFO, sizeof(SYSINFO), 1, fin); start = SYSINFO.StartDate; fclose(fin); } - sprintf(fnin, "%s/etc/mareas.data", getenv("MBSE_ROOT")); - sprintf(fnout, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); + snprintf(fnin, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(fnout, PATH_MAX, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); if ((fin = fopen(fnin, "r")) != NULL) { if ((fout = fopen(fnout, "w")) != NULL) { MsgUpdated = 0; @@ -244,7 +244,7 @@ int OpenMsgarea(void) msgs.Created = start; #ifndef USE_NEWSGATE if ((strlen(msgs.Newsgroup) == 0) && (msgs.Type == ECHOMAIL) && strlen(msgs.Group)) { - sprintf(msgs.Newsgroup, "%s.%s", GetFidoDomain(msgs.Aka.zone), msgs.Tag); + snprintf(msgs.Newsgroup, 81, "%s.%s", GetFidoDomain(msgs.Aka.zone), msgs.Tag); for (i = 0; i < strlen(msgs.Newsgroup); i++) { msgs.Newsgroup[i] = tolower(msgs.Newsgroup[i]); if (msgs.Newsgroup[i] == '_') @@ -292,8 +292,8 @@ void CloseMsgarea(int Force) { char fin[PATH_MAX], fout[PATH_MAX]; - sprintf(fin, "%s/etc/mareas.data", getenv("MBSE_ROOT")); - sprintf(fout,"%s/etc/mareas.temp", getenv("MBSE_ROOT")); + snprintf(fin, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(fout, PATH_MAX, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); if (MsgUpdated == 1) { if (Force || (yes_no((char *)"Messages database is changed, save changes") == 1)) { @@ -346,7 +346,7 @@ int AppendMsgarea() struct _sysconnect syscon; int i; - sprintf(ffile, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); + snprintf(ffile, PATH_MAX, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); if ((fil = fopen(ffile, "a")) != NULL) { InitMsgRec(); fwrite(&msgs, sizeof(msgs), 1, fil); @@ -466,10 +466,10 @@ int EditConnections(FILE *fil) if (System.aka.zone) { set_color(CYAN,BLACK); - sprintf(temp, "%3d. %s %s", o+i, status, aka2str(System.aka)); + snprintf(temp, 81, "%3d. %s %s", o+i, status, aka2str(System.aka)); } else { set_color(LIGHTBLUE, BLACK); - sprintf(temp, "%3d.", o+i); + snprintf(temp, 81, "%3d.", o+i); } mbse_mvprintw(y, x, temp); y++; @@ -563,7 +563,7 @@ long LoadMsgRec(int Area, int work) sysconnect System; int i; - sprintf(mfile, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); + snprintf(mfile, PATH_MAX, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); if ((fil = fopen(mfile, "r")) == NULL) { working(2, 0, 0); return -1; @@ -609,7 +609,7 @@ int SaveMsgRec(int Area, int work) if (work) working(1, 0, 0); - sprintf(mfile, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); + snprintf(mfile, PATH_MAX, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); if ((fil = fopen(mfile, "r+")) == 0) { working(2, 0, 0); return -1; @@ -654,21 +654,21 @@ void DeleteRules(char *filename) if (de->d_name[0] != '.') { strcpy(temp, msgs.Tag); if (strcasecmp(de->d_name, temp) == 0) { - sprintf(temp, "%s/%s", CFG.rulesdir, de->d_name); + snprintf(temp, PATH_MAX, "%s/%s", CFG.rulesdir, de->d_name); Syslog('+', "unlink(%s) rc=%d", temp, unlink(temp)); break; } - sprintf(temp, "%s.rul", msgs.Tag); + snprintf(temp, PATH_MAX, "%s.rul", msgs.Tag); if (strcasecmp(de->d_name, temp) == 0) { - sprintf(temp, "%s/%s", CFG.rulesdir, de->d_name); + snprintf(temp, PATH_MAX, "%s/%s", CFG.rulesdir, de->d_name); Syslog('+', "unlink(%s) rc=%d", temp, unlink(temp)); break; } memset(&temp, 0, sizeof(temp)); strncpy(temp, msgs.Tag, 8); - sprintf(temp, "%s.rul", temp); + snprintf(temp, PATH_MAX, "%s.rul", temp); if (strcasecmp(de->d_name, temp) == 0) { - sprintf(temp, "%s/%s", CFG.rulesdir, de->d_name); + snprintf(temp, PATH_MAX, "%s/%s", CFG.rulesdir, de->d_name); Syslog('+', "unlink(%s) rc=%d", temp, unlink(temp)); break; } @@ -716,7 +716,7 @@ void MsgGlobal(void) * Build the groups select array */ working(1, 0, 0); - sprintf(mfile, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + snprintf(mfile, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); if ((fil = fopen(mfile, "r")) != NULL) { fread(&mgrouphdr, sizeof(mgrouphdr), 1, fil); @@ -740,7 +740,7 @@ void MsgGlobal(void) S.sendto = TRUE; S.receivefrom = TRUE; memset(&mfile, 0, sizeof(mfile)); - sprintf(mfile, "%s", CFG.origin); + snprintf(mfile, 81, "%s", CFG.origin); daysold = CFG.defdays; maxmsgs = CFG.defmsgs; maxarticles = CFG.maxarticles; @@ -907,7 +907,7 @@ void MsgGlobal(void) Sc.aka.point = a2.point; Sc.sendto = TRUE; Sc.receivefrom = TRUE; - sprintf(Sc.aka.domain, "%s", a2.domain); + snprintf(Sc.aka.domain, 13, "%s", a2.domain); fwrite(&Sc, sizeof(sysconnect), 1, tfil); if (SaveMsgRec(marea, FALSE) == 0) { Done++; @@ -925,7 +925,7 @@ void MsgGlobal(void) Sc.aka.net = a2.net; Sc.aka.node = a2.node; Sc.aka.point = a2.point; - sprintf(Sc.aka.domain, "%s", a2.domain); + snprintf(Sc.aka.domain, 13, "%s", a2.domain); fseek(tfil, - sizeof(sysconnect), SEEK_CUR); fwrite(&Sc, sizeof(sysconnect), 1, tfil); if (SaveMsgRec(marea, FALSE) == 0) { @@ -1014,7 +1014,7 @@ void MsgGlobal(void) msgs.Aka.net = CFG.aka[akan].net; msgs.Aka.node = CFG.aka[akan].node; msgs.Aka.point = CFG.aka[akan].point; - sprintf(msgs.Aka.domain, "%s", CFG.aka[akan].domain); + snprintf(msgs.Aka.domain, 13, "%s", CFG.aka[akan].domain); if (SaveMsgRec(marea, FALSE) == 0) { Done++; Syslog('+', "Area %s now uses aka %s", msgs.Tag, aka2str(msgs.Aka)); @@ -1023,7 +1023,7 @@ void MsgGlobal(void) } break; case 11:if (strcmp(msgs.Origin, mfile)) { - sprintf(msgs.Origin, "%s", mfile); + snprintf(msgs.Origin, 65, "%s", mfile); if (SaveMsgRec(marea, FALSE) == 0) { Done++; Syslog('+', "Changed origin line in area %s", msgs.Tag); @@ -1230,7 +1230,7 @@ int EditMsgRec(int Area) */ temp = calloc(PATH_MAX, sizeof(char)); if (strlen(mgroup.BasePath)) { - sprintf(temp, "%s", msgs.Tag); + snprintf(temp, 81, "%s", msgs.Tag); for (i = 0; i < strlen(temp); i++) { if (isupper(temp[i])) temp[i] = tolower(temp[i]); @@ -1241,9 +1241,9 @@ int EditMsgRec(int Area) if (temp[i] == '.') temp[i] = '/'; } - sprintf(msgs.Base, "%s/%s", mgroup.BasePath, temp); + snprintf(msgs.Base, 65, "%s/%s", mgroup.BasePath, temp); } else { - sprintf(temp, "%s/%s", msgs.Group, msgs.Tag); + snprintf(temp, 81, "%s/%s", msgs.Group, msgs.Tag); for (i = 0; i < strlen(temp); i++) { if (isupper(temp[i])) temp[i] = tolower(temp[i]); @@ -1254,7 +1254,7 @@ int EditMsgRec(int Area) if (temp[i] == '.') temp[i] = '/'; } - sprintf(msgs.Base, "%s/var/mail/%s", getenv("MBSE_ROOT"), temp); + snprintf(msgs.Base, 65, "%s/var/mail/%s", getenv("MBSE_ROOT"), temp); } free(temp); /* @@ -1268,24 +1268,24 @@ int EditMsgRec(int Area) SetScreen(); break; case 4: E_STR( 9,16,64,msgs.Newsgroup, "The ^Newsgroup^ name of this area") - case 5: sprintf(oldpath, "%s", msgs.Base); + case 5: snprintf(oldpath, 81, "%s", msgs.Base); strcpy(msgs.Base, edit_jam(10,16,64,msgs.Base ,(char *)"The path to the ^JAM Message Base^")); if (strcmp(oldpath, msgs.Base)) { i = 0; temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s/etc/scanmgr.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/scanmgr.data", getenv("MBSE_ROOT")); if ((fil = fopen(temp, "r+")) != NULL) { fread(&scanmgrhdr, sizeof(scanmgrhdr), 1, fil); while (fread(&scanmgr, scanmgrhdr.recsize, 1, fil) == 1) { if (strcmp(oldpath, scanmgr.ScanBoard) == 0) { i++; - sprintf(scanmgr.ScanBoard, "%s", msgs.Base); + snprintf(scanmgr.ScanBoard, 51, "%s", msgs.Base); fseek(fil, - scanmgrhdr.recsize, SEEK_CUR); fwrite(&scanmgr, scanmgrhdr.recsize, 1, fil); } if (strcmp(oldpath, scanmgr.ReplBoard) == 0) { i++; - sprintf(scanmgr.ReplBoard, "%s", msgs.Base); + snprintf(scanmgr.ReplBoard, 51, "%s", msgs.Base); fseek(fil, - scanmgrhdr.recsize, SEEK_CUR); fwrite(&scanmgr, scanmgrhdr.recsize, 1, fil); } @@ -1296,13 +1296,13 @@ int EditMsgRec(int Area) } i = 0; - sprintf(temp, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); if ((fil = fopen(temp, "r+")) != NULL) { fread(&newfileshdr, sizeof(newfileshdr), 1, fil); while (fread(&newfiles, newfileshdr.recsize, 1, fil) == 1) { if (strcmp(oldpath, newfiles.Area) == 0) { i++; - sprintf(newfiles.Area, "%s", msgs.Base); + snprintf(newfiles.Area, 51, "%s", msgs.Base); fseek(fil, - newfileshdr.recsize, SEEK_CUR); fwrite(&newfiles, newfileshdr.recsize, 1, fil); } @@ -1340,7 +1340,7 @@ int EditMsgRec(int Area) } if (!Active) { temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s.jhr", msgs.Base); + snprintf(temp, PATH_MAX, "%s.jhr", msgs.Base); if (strlen(msgs.Base) && (file_size(temp) != 1024)) { if (yes_no((char *)"There are messages in this area, delete them") == 0) Active = TRUE; @@ -1442,7 +1442,7 @@ void EditMsgarea(void) mbse_mvprintw( 5, 3, "9.2 MESSAGE AREA SETUP"); set_color(CYAN, BLACK); if (records != 0) { - sprintf(temp, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.temp", getenv("MBSE_ROOT")); working(1, 0, 0); if ((fil = fopen(temp, "r")) != NULL) { fread(&msgshdr, sizeof(msgshdr), 1, fil); @@ -1455,10 +1455,10 @@ void EditMsgarea(void) fread(&msgs, msgshdr.recsize, 1, fil); if (msgs.Active) { set_color(CYAN, BLACK); - sprintf(temp, "%3d. %-8s %-23s %-40s", o + i, getmsgtype(msgs.Type), msgs.Tag, msgs.Name); + snprintf(temp, 81, "%3d. %-8s %-23s %-40s", o + i, getmsgtype(msgs.Type), msgs.Tag, msgs.Name); } else { set_color(LIGHTBLUE, BLACK); - sprintf(temp, "%3d.", o+i); + snprintf(temp, 81, "%3d.", o+i); } mbse_mvprintw(y, 2, temp); y++; @@ -1597,12 +1597,12 @@ char *PickMsgarea(char *shdr) for (;;) { clr_index(); set_color(WHITE, BLACK); - sprintf(temp, "%s. MESSAGE AREA SELECT", shdr); + snprintf(temp, 81, "%s. MESSAGE AREA SELECT", shdr); mbse_mvprintw(5, 3, temp); set_color(CYAN, BLACK); if (records) { - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); working(1, 0, 0); if ((fil = fopen(temp, "r")) != NULL) { fread(&msgshdr, sizeof(msgshdr), 1, fil); @@ -1622,7 +1622,7 @@ char *PickMsgarea(char *shdr) set_color(CYAN, BLACK); else set_color(LIGHTBLUE, BLACK); - sprintf(temp, "%3d. %-31s", o + i, msgs.Name); + snprintf(temp, 81, "%3d. %-31s", o + i, msgs.Name); temp[38] = '\0'; mbse_mvprintw(y, x, temp); y++; @@ -1645,7 +1645,7 @@ char *PickMsgarea(char *shdr) o -= 20; if ((atoi(pick) >= 1) && (atoi(pick) <= records)) { - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((fil = fopen(temp, "r")) != NULL) { offset = msgshdr.hdrsize + ((atoi(pick) - 1) * (msgshdr.recsize + msgshdr.syssize)); fseek(fil, offset, SEEK_SET); @@ -1653,7 +1653,7 @@ char *PickMsgarea(char *shdr) fclose(fil); if (msgs.Active) { memset(&Buf, 0, sizeof(Buf)); - sprintf(Buf, "%s", msgs.Base); + snprintf(Buf, 81, "%s", msgs.Base); return Buf; } } @@ -1669,7 +1669,7 @@ int GroupInMarea(char *Group) FILE *no; char temp[PATH_MAX]; - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return 0; @@ -1702,7 +1702,7 @@ int NodeInMarea(fidoaddr A) char temp[PATH_MAX]; sysconnect S; - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return 0; @@ -1736,7 +1736,7 @@ void msged_areas(FILE *fp) int i = 0; temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return; @@ -1788,7 +1788,7 @@ void gold_areas(FILE *fp) int i = 0; temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return; @@ -1854,7 +1854,7 @@ int mail_area_doc(FILE *fp, FILE *toc, int page) else LMiy = Miy - 1; - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return page; @@ -1883,7 +1883,7 @@ int mail_area_doc(FILE *fp, FILE *toc, int page) } else fprintf(fp, "\n\n"); - sprintf(temp, "msgarea_%d.html", i); + snprintf(temp, 81, "msgarea_%d.html", i); fprintf(ip, " %d%s%s\n", temp, i, msgs.Name, strlen(msgs.Tag) ? msgs.Tag : " "); if ((wp = open_webdoc(temp, (char *)"File area", msgs.Name))) { @@ -1986,7 +1986,7 @@ int mail_area_doc(FILE *fp, FILE *toc, int page) fprintf(fp, " Link %2d %s %s\n", j+1, status, aka2str(System.aka)); if (wp != NULL) { - sprintf(temp, "%s/etc/nodes.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/nodes.data", getenv("MBSE_ROOT")); if ((ti = fopen(temp, "r"))) { fread(&nodeshdr, sizeof(nodeshdr), 1, ti); fseek(ti, 0, SEEK_SET); diff --git a/mbsetup/m_menu.c b/mbsetup/m_menu.c index f313a3cb..eb1a510c 100644 --- a/mbsetup/m_menu.c +++ b/mbsetup/m_menu.c @@ -4,7 +4,7 @@ * Purpose ...............: Edit BBS menus * ***************************************************************************** - * Copyright (C) 1997-2004 + * Copyright (C) 1997-2005 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -47,13 +47,13 @@ char *select_menurec(int max) int pick; if (max > 10) - sprintf(help, "Rec. (1..%d), ^\"-\"^ Back, ^A^ppend, ^D^elete, ^M^ove, ^P^revious, ^N^ext", max); + snprintf(help, 81, "Rec. (1..%d), ^\"-\"^ Back, ^A^ppend, ^D^elete, ^M^ove, ^P^revious, ^N^ext", max); else if (max > 1) - sprintf(help, "Rec. (1..%d), ^\"-\"^ Back, ^A^ppend, ^D^elete, ^M^ove", max); + snprintf(help, 81, "Rec. (1..%d), ^\"-\"^ Back, ^A^ppend, ^D^elete, ^M^ove", max); else if (max == 1) - sprintf(help, "Rec. (1..%d), ^\"-\"^ Back, ^A^ppend, ^D^elete", max); + snprintf(help, 81, "Rec. (1..%d), ^\"-\"^ Back, ^A^ppend, ^D^elete", max); else - sprintf(help, "Select ^\"-\"^ for previous level, ^A^ppend a record"); + snprintf(help, 81, "Select ^\"-\"^ for previous level, ^A^ppend a record"); showhelp(help); @@ -157,7 +157,7 @@ int GetSubmenu(int Base, int Max) x = 2; for (i = 1; i <= Max; i++) { - sprintf(temp, "%2d. %s", i, getmenutype(i - 1 + Base)); + snprintf(temp, 81, "%2d. %s", i, getmenutype(i - 1 + Base)); mbse_mvprintw(y, x, temp); y++; if ((i % 13) == 0) { @@ -316,10 +316,10 @@ void EditMenu(char *Name) IsDoing("Edit Menu"); working(1, 0, 0); - sprintf(mtemp, "%s/%s.tmp", lang.MenuPath, Name); + snprintf(mtemp, PATH_MAX, "%s/%s.tmp", lang.MenuPath, Name); tmp = fopen(mtemp, "w+"); - sprintf(temp, "%s/%s.mnu", lang.MenuPath, Name); + snprintf(temp, PATH_MAX, "%s/%s.mnu", lang.MenuPath, Name); if ((fil = fopen(temp, "r")) != NULL) { while (fread(&menus, sizeof(menus), 1, fil) == 1) { fwrite(&menus, sizeof(menus), 1, tmp); @@ -332,7 +332,7 @@ void EditMenu(char *Name) for (;;) { clr_index(); working(1, 0, 0); - sprintf(temp, "8.3 EDIT MENU \"%s\" (%s)", Name, lang.Name); + snprintf(temp, 81, "8.3 EDIT MENU \"%s\" (%s)", Name, lang.Name); mbse_mvprintw( 5, 6, tu(temp)); set_color(CYAN, BLACK); fseek(tmp, 0, SEEK_SET); @@ -355,9 +355,11 @@ void EditMenu(char *Name) mbse_mvprintw(y, 10, "%1s", menus.MenuKey); } if (le_int(menus.MenuType) == 999 ) { - sprintf(temp, "%-29s %5d %s", menus.TypeDesc, le_int(menus.MenuSecurity.level), menus.Display); + snprintf(temp, 81, "%-29s %5d %s", menus.TypeDesc, + le_int(menus.MenuSecurity.level), menus.Display); } else { - sprintf(temp, "%-29s %5d %s", menus.TypeDesc, le_int(menus.MenuSecurity.level), menus.OptionalData); + snprintf(temp, 81, "%-29s %5d %s", menus.TypeDesc, + le_int(menus.MenuSecurity.level), menus.OptionalData); } temp[68] = '\0'; mbse_mvprintw(y, 12, temp); @@ -376,7 +378,7 @@ void EditMenu(char *Name) if (MenuUpdated) { if (yes_no((char *)"Menu is changed, save changes") == 1) { working(1, 0, 0); - sprintf(temp, "%s/%s.mnu", lang.MenuPath, Name); + snprintf(temp, PATH_MAX, "%s/%s.mnu", lang.MenuPath, Name); if ((fil = fopen(temp, "w+")) == NULL) { working(2, 0, 0); } else { @@ -527,7 +529,7 @@ void EditMenus(void) y = 7; set_color(CYAN, BLACK); for (i = 1; i <= mcount; i++) { - sprintf(temp, "%2d. %s", i, menuname[i-1]); + snprintf(temp, 81, "%2d. %s", i, menuname[i-1]); mbse_mvprintw(y, x, temp); y++; if ((i % 10) == 0) { @@ -585,7 +587,7 @@ int bbs_menu_doc(FILE *fp, FILE *toc, int page) int j; temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s/etc/language.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/language.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) { free(temp); return page; @@ -609,10 +611,10 @@ int bbs_menu_doc(FILE *fp, FILE *toc, int page) if (de->d_name[0] != '.') { j = 0; fprintf(ip, "
  • %s
  • \n", lang.LangKey, de->d_name, de->d_name); - sprintf(temp, "%s/%s", lang.MenuPath, de->d_name); + snprintf(temp, PATH_MAX, "%s/%s", lang.MenuPath, de->d_name); fprintf(fp, "\n MENU %s (%s)\n\n", de->d_name, lang.Name); if ((mn = fopen(temp, "r")) != NULL) { - sprintf(temp, "menu_%s_%s.html", lang.LangKey, de->d_name); + snprintf(temp, 81, "menu_%s_%s.html", lang.LangKey, de->d_name); if ((wp = open_webdoc(temp, lang.Name, de->d_name))) { fprintf(wp, "Main Back\n"); while (fread(&menus, sizeof(menus), 1, mn) == 1) { @@ -628,7 +630,7 @@ int bbs_menu_doc(FILE *fp, FILE *toc, int page) fprintf(fp, " Menu select Autoexec\n"); add_webtable(wp, (char *)"Menu select", (char *)"Autoexec"); } - sprintf(temp, "%d %s", le_int(menus.MenuType), menus.TypeDesc); + snprintf(temp, 81, "%d %s", le_int(menus.MenuType), menus.TypeDesc); add_webtable(wp, (char *)"Menu type", temp); add_webtable(wp, (char *)"Optional data", menus.OptionalData); add_webtable(wp, (char *)"Display", menus.Display); diff --git a/mbsetup/m_mgroup.c b/mbsetup/m_mgroup.c index b58f1727..8840f077 100644 --- a/mbsetup/m_mgroup.c +++ b/mbsetup/m_mgroup.c @@ -54,7 +54,7 @@ int CountMGroup(void) char ffile[PATH_MAX]; int count; - sprintf(ffile, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + snprintf(ffile, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "a+")) != NULL) { Syslog('+', "Created new %s", ffile); @@ -62,13 +62,13 @@ int CountMGroup(void) mgrouphdr.recsize = sizeof(mgroup); fwrite(&mgrouphdr, sizeof(mgrouphdr), 1, fil); memset(&mgroup, 0, sizeof(mgroup)); - sprintf(mgroup.Name, "NOGROUP"); - sprintf(mgroup.Comment, "Dummy group for badmail, dupemail"); + snprintf(mgroup.Name, 13, "NOGROUP"); + snprintf(mgroup.Comment, 56, "Dummy group for badmail, dupemail"); mgroup.Active = TRUE; fwrite(&mgroup, sizeof(mgroup), 1, fil); memset(&mgroup, 0, sizeof(mgroup)); - sprintf(mgroup.Name, "LOCAL"); - sprintf(mgroup.Comment, "Local mail areas"); + snprintf(mgroup.Name, 13, "LOCAL"); + snprintf(mgroup.Comment, 56, "Local mail areas"); mgroup.Active = TRUE; fwrite(&mgroup, sizeof(mgroup), 1, fil); fclose(fil); @@ -103,8 +103,8 @@ int OpenMGroup(void) long oldsize; int i; - sprintf(fnin, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); - sprintf(fnout, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); + snprintf(fnin, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + snprintf(fnout, PATH_MAX, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); if ((fin = fopen(fnin, "r")) != NULL) { if ((fout = fopen(fnout, "w")) != NULL) { MGrpUpdated = 0; @@ -148,7 +148,7 @@ int OpenMGroup(void) if (temp[i] == '.') temp[i] = '/'; } - sprintf(mgroup.BasePath, "%s/var/mail/%s", getenv("MBSE_ROOT"), temp); + snprintf(mgroup.BasePath, 65, "%s/var/mail/%s", getenv("MBSE_ROOT"), temp); } if (MGrpUpdated && !mgroup.LinkSec.level) { mgroup.LinkSec.level = 1; @@ -179,8 +179,8 @@ void CloseMGroup(int force) FILE *fi, *fo; st_list *mgr = NULL, *tmp; - sprintf(fin, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); - sprintf(fout,"%s/etc/mgroups.temp", getenv("MBSE_ROOT")); + snprintf(fin, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + snprintf(fout, PATH_MAX, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); if (MGrpUpdated == 1) { if (force || (yes_no((char *)"Database is changed, save changes") == 1)) { @@ -225,7 +225,7 @@ int AppendMGroup(void) FILE *fil; char ffile[PATH_MAX]; - sprintf(ffile, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); + snprintf(ffile, PATH_MAX, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); if ((fil = fopen(ffile, "a")) != NULL) { memset(&mgroup, 0, sizeof(mgroup)); mgroup.StartDate = time(NULL); @@ -309,7 +309,7 @@ int EditMGrpRec(int Area) working(1, 0, 0); IsDoing("Edit MessageGroup"); - sprintf(mfile, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); + snprintf(mfile, PATH_MAX, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); if ((fil = fopen(mfile, "r")) == NULL) { working(2, 0, 0); return -1; @@ -389,7 +389,7 @@ int EditMGrpRec(int Area) if (isupper(temp[i])) temp[i] = tolower(temp[i]); } - sprintf(mgroup.BasePath, "%s/var/mail/%s", getenv("MBSE_ROOT"), temp); + snprintf(mgroup.BasePath, 65, "%s/var/mail/%s", getenv("MBSE_ROOT"), temp); } break; case 2: E_STR( 8,16,55, mgroup.Comment, "The ^desription^ for this message group") @@ -472,7 +472,7 @@ void EditMGroup(void) mbse_mvprintw( 5, 4, "9.1 MESSAGE GROUPS SETUP"); set_color(CYAN, BLACK); if (records != 0) { - sprintf(temp, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mgroups.temp", getenv("MBSE_ROOT")); working(1, 0, 0); if ((fil = fopen(temp, "r")) != NULL) { fread(&mgrouphdr, sizeof(mgrouphdr), 1, fil); @@ -492,7 +492,7 @@ void EditMGroup(void) set_color(CYAN, BLACK); else set_color(LIGHTBLUE, BLACK); - sprintf(temp, "%3d. %-12s %-18s", o + i, mgroup.Name, mgroup.Comment); + snprintf(temp, 81, "%3d. %-12s %-18s", o + i, mgroup.Name, mgroup.Comment); temp[38] = '\0'; mbse_mvprintw(y, x, temp); y++; @@ -576,11 +576,11 @@ char *PickMGroup(char *shdr) for (;;) { clr_index(); set_color(WHITE, BLACK); - sprintf(temp, "%s. MESSAGE GROUP SELECT", shdr); + snprintf(temp, 81, "%s. MESSAGE GROUP SELECT", shdr); mbse_mvprintw( 5, 4, temp); set_color(CYAN, BLACK); if (records != 0) { - sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); working(1, 0, 0); if ((fil = fopen(temp, "r")) != NULL) { fread(&mgrouphdr, sizeof(mgrouphdr), 1, fil); @@ -600,7 +600,7 @@ char *PickMGroup(char *shdr) set_color(CYAN, BLACK); else set_color(LIGHTBLUE, BLACK); - sprintf(temp, "%3d. %-12s %-18s", o + i, mgroup.Name, mgroup.Comment); + snprintf(temp, 81, "%3d. %-12s %-18s", o + i, mgroup.Name, mgroup.Comment); temp[38] = '\0'; mbse_mvprintw(y, x, temp); y++; @@ -623,7 +623,7 @@ char *PickMGroup(char *shdr) o = o - 20; if ((atoi(pick) >= 1) && (atoi(pick) <= records)) { - sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); fil = fopen(temp, "r"); offset = sizeof(mgrouphdr) + ((atoi(pick) - 1) * mgrouphdr.recsize); fseek(fil, offset, 0); @@ -643,7 +643,7 @@ int mail_group_doc(FILE *fp, FILE *toc, int page) FILE *ti, *wp, *ip, *no; int refs, i, j; - sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return page; @@ -669,7 +669,7 @@ int mail_group_doc(FILE *fp, FILE *toc, int page) j = 0; } - sprintf(temp, "msggroup_%s.html", mgroup.Name); + snprintf(temp, 81, "msggroup_%s.html", mgroup.Name); fprintf(ip, " %s%s%s\n", temp, mgroup.Name, mgroup.Comment, getboolean(mgroup.Active)); @@ -704,7 +704,7 @@ int mail_group_doc(FILE *fp, FILE *toc, int page) fprintf(wp, "
    \n"); fprintf(wp, "

    Message Areas Reference

    \n"); refs = 0; - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((ti = fopen(temp, "r"))) { fread(&tichdr, sizeof(tichdr), 1, ti); fseek(ti, 0, SEEK_SET); @@ -735,7 +735,7 @@ int mail_group_doc(FILE *fp, FILE *toc, int page) fprintf(wp, "
    \n"); fprintf(wp, "

    Nodes Reference

    \n"); refs = 0; - sprintf(temp, "%s/etc/nodes.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/nodes.data", getenv("MBSE_ROOT")); if ((ti = fopen(temp, "r"))) { fread(&nodeshdr, sizeof(nodeshdr), 1, ti); fseek(ti, 0, SEEK_SET); diff --git a/mbsetup/m_modem.c b/mbsetup/m_modem.c index 4a8574b7..59ef2afb 100644 --- a/mbsetup/m_modem.c +++ b/mbsetup/m_modem.c @@ -4,7 +4,7 @@ * Purpose ...............: Setup Modem structure. * ***************************************************************************** - * Copyright (C) 1997-2004 + * Copyright (C) 1997-2005 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -52,7 +52,7 @@ int CountModem(void) char ffile[PATH_MAX]; int count; - sprintf(ffile, "%s/etc/modem.data", getenv("MBSE_ROOT")); + snprintf(ffile, PATH_MAX, "%s/etc/modem.data", getenv("MBSE_ROOT")); if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "a+")) != NULL) { Syslog('+', "Created new %s", ffile); @@ -64,78 +64,78 @@ int CountModem(void) * Create some default modem types */ memset(&modem, 0, sizeof(modem)); - sprintf(modem.modem, "Dynalink 1428EXTRA"); - sprintf(modem.init[0], "AT Z\\r"); - sprintf(modem.init[1], "AT &F &C1 &D2 X4 W2 B0 M0 \\\\V1 \\\\G0 &K3 S37=0\\r"); - sprintf(modem.ok, "OK"); - sprintf(modem.dial, "ATDT\\T\\r"); - sprintf(modem.connect[0], "CONNECT 56000"); - sprintf(modem.connect[1], "CONNECT 48000"); - sprintf(modem.connect[2], "CONNECT 44000"); - sprintf(modem.connect[3], "CONNECT 41333"); - sprintf(modem.connect[4], "CONNECT 38000"); - sprintf(modem.connect[5], "CONNECT 33600"); - sprintf(modem.connect[6], "CONNECT 31200"); - sprintf(modem.connect[7], "CONNECT 28800"); - sprintf(modem.connect[8], "CONNECT 26400"); - sprintf(modem.connect[9], "CONNECT 24000"); - sprintf(modem.connect[10], "CONNECT 21600"); - sprintf(modem.connect[11], "CONNECT 19200"); - sprintf(modem.connect[12], "CONNECT 16800"); - sprintf(modem.connect[13], "CONNECT 14400"); - sprintf(modem.connect[14], "CONNECT 12000"); - sprintf(modem.connect[15], "CONNECT 9600"); - sprintf(modem.connect[16], "CONNECT 7200"); - sprintf(modem.connect[17], "CONNECT 4800"); - sprintf(modem.connect[18], "CONNECT 2400"); - sprintf(modem.connect[19], "CONNECT"); - sprintf(modem.reset, "AT&F&C1&D2X4W2B0M0&K3\\r"); - sprintf(modem.error[0], "BUSY"); - sprintf(modem.error[1], "NO CARRIER"); - sprintf(modem.error[2], "NO DIALTONE"); - sprintf(modem.error[3], "NO ANSWER"); - sprintf(modem.error[4], "RING\\r"); - sprintf(modem.error[5], "ERROR"); - sprintf(modem.error[6], "CONNECT VOICE"); - sprintf(modem.speed, "28800"); + snprintf(modem.modem, 31, "Dynalink 1428EXTRA"); + snprintf(modem.init[0], 61, "AT Z\\r"); + snprintf(modem.init[1], 61, "AT &F &C1 &D2 X4 W2 B0 M0 \\\\V1 \\\\G0 &K3 S37=0\\r"); + snprintf(modem.ok, 11, "OK"); + snprintf(modem.dial, 41, "ATDT\\T\\r"); + snprintf(modem.connect[0], 31, "CONNECT 56000"); + snprintf(modem.connect[1], 31, "CONNECT 48000"); + snprintf(modem.connect[2], 31, "CONNECT 44000"); + snprintf(modem.connect[3], 31, "CONNECT 41333"); + snprintf(modem.connect[4], 31, "CONNECT 38000"); + snprintf(modem.connect[5], 31, "CONNECT 33600"); + snprintf(modem.connect[6], 31, "CONNECT 31200"); + snprintf(modem.connect[7], 31, "CONNECT 28800"); + snprintf(modem.connect[8], 31, "CONNECT 26400"); + snprintf(modem.connect[9], 31, "CONNECT 24000"); + snprintf(modem.connect[10], 31, "CONNECT 21600"); + snprintf(modem.connect[11], 31, "CONNECT 19200"); + snprintf(modem.connect[12], 31, "CONNECT 16800"); + snprintf(modem.connect[13], 31, "CONNECT 14400"); + snprintf(modem.connect[14], 31, "CONNECT 12000"); + snprintf(modem.connect[15], 31, "CONNECT 9600"); + snprintf(modem.connect[16], 31, "CONNECT 7200"); + snprintf(modem.connect[17], 31, "CONNECT 4800"); + snprintf(modem.connect[18], 31, "CONNECT 2400"); + snprintf(modem.connect[19], 31, "CONNECT"); + snprintf(modem.reset, 61, "AT&F&C1&D2X4W2B0M0&K3\\r"); + snprintf(modem.error[0], 21, "BUSY"); + snprintf(modem.error[1], 21, "NO CARRIER"); + snprintf(modem.error[2], 21, "NO DIALTONE"); + snprintf(modem.error[3], 21, "NO ANSWER"); + snprintf(modem.error[4], 21, "RING\\r"); + snprintf(modem.error[5], 21, "ERROR"); + snprintf(modem.error[6], 21, "CONNECT VOICE"); + snprintf(modem.speed, 16, "28800"); modem.available = TRUE; modem.costoffset = 6; fwrite(&modem, sizeof(modem), 1, fil); - sprintf(modem.modem, "ISDN Dynalink"); - sprintf(modem.init[0], "ATZ\\r"); - sprintf(modem.init[1], "AT&E3306018793\\r"); - sprintf(modem.init[2], "AT&B512\\r"); - sprintf(modem.hangup, "ATH0\\r"); - sprintf(modem.speed, "64000"); + snprintf(modem.modem, 31, "ISDN Dynalink"); + snprintf(modem.init[0], 61, "ATZ\\r"); + snprintf(modem.init[1], 61, "AT&E3306018793\\r"); + snprintf(modem.init[2], 61, "AT&B512\\r"); + snprintf(modem.hangup, 41, "ATH0\\r"); + snprintf(modem.speed, 16, "64000"); modem.costoffset = 1; fwrite(&modem, sizeof(modem), 1, fil); - sprintf(modem.modem, "Standard Hayes V34"); - sprintf(modem.init[0], "ATZ\\r"); + snprintf(modem.modem, 31, "Standard Hayes V34"); + snprintf(modem.init[0], 61, "ATZ\\r"); memset(&modem.init[1], 0, sizeof(modem.init[1])); memset(&modem.init[2], 0, sizeof(modem.init[2])); memset(&modem.hangup, 0, sizeof(modem.hangup)); - sprintf(modem.speed, "33600"); + snprintf(modem.speed, 16, "33600"); modem.costoffset = 6; fwrite(&modem, sizeof(modem), 1, fil); memset(&modem, 0, sizeof(modem)); - sprintf(modem.modem, "ISDN Linux"); - sprintf(modem.init[0], "AT Z\\r"); - sprintf(modem.ok, "OK"); - sprintf(modem.dial, "ATDT\\T\\r"); - sprintf(modem.info, "ATI2\\r"); - sprintf(modem.hangup, "\\d\\p\\p\\p+++\\d\\p\\p\\pATH0\\r"); - sprintf(modem.connect[0], "CONNECT 64000"); - sprintf(modem.connect[1], "CONNECT"); - sprintf(modem.error[0], "BUSY"); - sprintf(modem.error[1], "NO CARRIER"); - sprintf(modem.error[2], "NO DIALTONE"); - sprintf(modem.error[3], "NO ANSWER"); - sprintf(modem.error[4], "RING\\r"); - sprintf(modem.error[5], "ERROR"); - sprintf(modem.speed, "64000"); + snprintf(modem.modem, 31, "ISDN Linux"); + snprintf(modem.init[0], 61, "AT Z\\r"); + snprintf(modem.ok, 11, "OK"); + snprintf(modem.dial, 41, "ATDT\\T\\r"); + snprintf(modem.info, 41, "ATI2\\r"); + snprintf(modem.hangup, 41, "\\d\\p\\p\\p+++\\d\\p\\p\\pATH0\\r"); + snprintf(modem.connect[0], 31, "CONNECT 64000"); + snprintf(modem.connect[1], 31, "CONNECT"); + snprintf(modem.error[0], 21, "BUSY"); + snprintf(modem.error[1], 21, "NO CARRIER"); + snprintf(modem.error[2], 21, "NO DIALTONE"); + snprintf(modem.error[3], 21, "NO ANSWER"); + snprintf(modem.error[4], 21, "RING\\r"); + snprintf(modem.error[5], 21, "ERROR"); + snprintf(modem.speed, 16, "64000"); modem.available = TRUE; modem.costoffset = 1; fwrite(&modem, sizeof(modem), 1, fil); @@ -169,8 +169,8 @@ int OpenModem(void) char fnin[PATH_MAX], fnout[PATH_MAX]; long oldsize; - sprintf(fnin, "%s/etc/modem.data", getenv("MBSE_ROOT")); - sprintf(fnout, "%s/etc/modem.temp", getenv("MBSE_ROOT")); + snprintf(fnin, PATH_MAX, "%s/etc/modem.data", getenv("MBSE_ROOT")); + snprintf(fnout, PATH_MAX, "%s/etc/modem.temp", getenv("MBSE_ROOT")); if ((fin = fopen(fnin, "r")) != NULL) { if ((fout = fopen(fnout, "w")) != NULL) { fread(&modemhdr, sizeof(modemhdr), 1, fin); @@ -218,8 +218,8 @@ void CloseModem(int force) FILE *fi, *fo; st_list *mdm = NULL, *tmp; - sprintf(fin, "%s/etc/modem.data", getenv("MBSE_ROOT")); - sprintf(fout,"%s/etc/modem.temp", getenv("MBSE_ROOT")); + snprintf(fin, PATH_MAX, "%s/etc/modem.data", getenv("MBSE_ROOT")); + snprintf(fout, PATH_MAX, "%s/etc/modem.temp", getenv("MBSE_ROOT")); if (ModemUpdated == 1) { if (force || (yes_no((char *)"Database is changed, save changes") == 1)) { @@ -263,40 +263,40 @@ int AppendModem(void) FILE *fil; char ffile[PATH_MAX]; - sprintf(ffile, "%s/etc/modem.temp", getenv("MBSE_ROOT")); + snprintf(ffile, PATH_MAX, "%s/etc/modem.temp", getenv("MBSE_ROOT")); if ((fil = fopen(ffile, "a")) != NULL) { memset(&modem, 0, sizeof(modem)); - sprintf(modem.init[0], "ATZ\\r"); - sprintf(modem.ok, "OK"); - sprintf(modem.dial, "ATDT\\T\\r"); - sprintf(modem.connect[0], "CONNECT 56000"); - sprintf(modem.connect[1], "CONNECT 48000"); - sprintf(modem.connect[2], "CONNECT 44000"); - sprintf(modem.connect[3], "CONNECT 41333"); - sprintf(modem.connect[4], "CONNECT 38000"); - sprintf(modem.connect[5], "CONNECT 33600"); - sprintf(modem.connect[6], "CONNECT 31200"); - sprintf(modem.connect[7], "CONNECT 28800"); - sprintf(modem.connect[8], "CONNECT 26400"); - sprintf(modem.connect[9], "CONNECT 24000"); - sprintf(modem.connect[10], "CONNECT 21600"); - sprintf(modem.connect[11], "CONNECT 19200"); - sprintf(modem.connect[12], "CONNECT 16800"); - sprintf(modem.connect[13], "CONNECT 14400"); - sprintf(modem.connect[14], "CONNECT 12000"); - sprintf(modem.connect[15], "CONNECT 9600"); - sprintf(modem.connect[16], "CONNECT 7200"); - sprintf(modem.connect[17], "CONNECT 4800"); - sprintf(modem.connect[18], "CONNECT 2400"); - sprintf(modem.connect[19], "CONNECT"); - sprintf(modem.error[0], "BUSY"); - sprintf(modem.error[1], "NO CARRIER"); - sprintf(modem.error[2], "NO DIALTONE"); - sprintf(modem.error[3], "NO ANSWER"); - sprintf(modem.error[4], "RING\\r"); - sprintf(modem.error[5], "ERROR"); - sprintf(modem.speed, "28800"); - sprintf(modem.reset, "AT\\r"); + snprintf(modem.init[0], 61, "ATZ\\r"); + snprintf(modem.ok, 11, "OK"); + snprintf(modem.dial, 41, "ATDT\\T\\r"); + snprintf(modem.connect[0], 31, "CONNECT 56000"); + snprintf(modem.connect[1], 31, "CONNECT 48000"); + snprintf(modem.connect[2], 31, "CONNECT 44000"); + snprintf(modem.connect[3], 31, "CONNECT 41333"); + snprintf(modem.connect[4], 31, "CONNECT 38000"); + snprintf(modem.connect[5], 31, "CONNECT 33600"); + snprintf(modem.connect[6], 31, "CONNECT 31200"); + snprintf(modem.connect[7], 31, "CONNECT 28800"); + snprintf(modem.connect[8], 31, "CONNECT 26400"); + snprintf(modem.connect[9], 31, "CONNECT 24000"); + snprintf(modem.connect[10], 31, "CONNECT 21600"); + snprintf(modem.connect[11], 31, "CONNECT 19200"); + snprintf(modem.connect[12], 31, "CONNECT 16800"); + snprintf(modem.connect[13], 31, "CONNECT 14400"); + snprintf(modem.connect[14], 31, "CONNECT 12000"); + snprintf(modem.connect[15], 31, "CONNECT 9600"); + snprintf(modem.connect[16], 31, "CONNECT 7200"); + snprintf(modem.connect[17], 31, "CONNECT 4800"); + snprintf(modem.connect[18], 31, "CONNECT 2400"); + snprintf(modem.connect[19], 31, "CONNECT"); + snprintf(modem.error[0], 21, "BUSY"); + snprintf(modem.error[1], 21, "NO CARRIER"); + snprintf(modem.error[2], 21, "NO DIALTONE"); + snprintf(modem.error[3], 21, "NO ANSWER"); + snprintf(modem.error[4], 21, "RING\\r"); + snprintf(modem.error[5], 21, "ERROR"); + snprintf(modem.speed, 16, "28800"); + snprintf(modem.reset, 61, "AT\\r"); modem.available = TRUE; fwrite(&modem, sizeof(modem), 1, fil); fclose(fil); @@ -409,7 +409,7 @@ int EditModemRec(int Area) working(1, 0, 0); IsDoing("Edit Modem"); - sprintf(mfile, "%s/etc/modem.temp", getenv("MBSE_ROOT")); + snprintf(mfile, PATH_MAX, "%s/etc/modem.temp", getenv("MBSE_ROOT")); if ((fil = fopen(mfile, "r")) == NULL) { working(2, 0, 0); return -1; @@ -532,7 +532,7 @@ void EditModem(void) mbse_mvprintw( 5, 4, "5. MODEM TYPES SETUP"); set_color(CYAN, BLACK); if (records != 0) { - sprintf(temp, "%s/etc/modem.temp", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/modem.temp", getenv("MBSE_ROOT")); if ((fil = fopen(temp, "r")) != NULL) { fread(&modemhdr, sizeof(modemhdr), 1, fil); x = 2; @@ -550,7 +550,7 @@ void EditModem(void) set_color(CYAN, BLACK); else set_color(LIGHTBLUE, BLACK); - sprintf(temp, "%3d. %-30s", i, modem.modem); + snprintf(temp, 81, "%3d. %-30s", i, modem.modem); temp[37] = 0; mbse_mvprintw(y, x, temp); y++; @@ -617,11 +617,11 @@ char *PickModem(char *shdr) for (;;) { clr_index(); set_color(WHITE, BLACK); - sprintf(temp, "%s. MODEM SELECT", shdr); + snprintf(temp, 81, "%s. MODEM SELECT", shdr); mbse_mvprintw(5,3,temp); set_color(CYAN, BLACK); if (records) { - sprintf(temp, "%s/etc/modem.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/modem.data", getenv("MBSE_ROOT")); working(1, 0, 0); if ((fil = fopen(temp, "r")) != NULL) { fread(&modemhdr, sizeof(modemhdr), 1, fil); @@ -641,7 +641,7 @@ char *PickModem(char *shdr) set_color(CYAN, BLACK); else set_color(LIGHTBLUE, BLACK); - sprintf(temp, "%3d. %-31s", o + i, modem.modem); + snprintf(temp, 81, "%3d. %-31s", o + i, modem.modem); temp[38] = '\0'; mbse_mvprintw(y, x, temp); y++; @@ -664,14 +664,14 @@ char *PickModem(char *shdr) o -= 20; if ((atoi(pick) >= 1) && (atoi(pick) <= records)) { - sprintf(temp, "%s/etc/modem.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/modem.data", getenv("MBSE_ROOT")); if ((fil = fopen(temp, "r")) != NULL) { offset = modemhdr.hdrsize + ((atoi(pick) - 1) * modemhdr.recsize); fseek(fil, offset, SEEK_SET); fread(&modem, modemhdr.recsize, 1, fil); fclose(fil); if (modem.available) { - sprintf(buf, "%s", modem.modem); + snprintf(buf, 31, "%s", modem.modem); return buf; } } @@ -687,7 +687,7 @@ int modem_doc(FILE *fp, FILE *toc, int page) FILE *ti, *wp, *ip, *mdm; int refs, nr = 0, i, j; - sprintf(temp, "%s/etc/modem.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/modem.data", getenv("MBSE_ROOT")); if ((mdm = fopen(temp, "r")) == NULL) return page; @@ -715,7 +715,7 @@ int modem_doc(FILE *fp, FILE *toc, int page) nr++; fprintf(ip, " %d%s%s\n", nr, nr, modem.modem, getboolean(modem.available)); - sprintf(temp, "modem_%d.html", nr); + snprintf(temp, 81, "modem_%d.html", nr); if ((wp = open_webdoc(temp, (char *)"Modem", modem.modem))) { fprintf(wp, "Main Back\n"); fprintf(wp, "

    \n"); @@ -725,7 +725,7 @@ int modem_doc(FILE *fp, FILE *toc, int page) add_webtable(wp, (char *)"Modem type", modem.modem); for (i = 0; i < 3; i++) if (strlen(modem.init[i])) { - sprintf(temp, "Init string %d", i+1); + snprintf(temp, 81, "Init string %d", i+1); add_webtable(wp, temp, modem.init[i]); } add_webtable(wp, (char *)"OK string", modem.ok); @@ -748,7 +748,7 @@ int modem_doc(FILE *fp, FILE *toc, int page) fprintf(wp, "


    \n"); fprintf(wp, "

    TTY Lines Reference

    \n"); refs = 0; - sprintf(temp, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT")); if ((ti = fopen(temp, "r"))) { fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, ti); fseek(ti, 0, SEEK_SET); diff --git a/mbsetup/m_new.c b/mbsetup/m_new.c index 48b045ae..239f3364 100644 --- a/mbsetup/m_new.c +++ b/mbsetup/m_new.c @@ -4,7 +4,7 @@ * Purpose ...............: Newfiles Setup * ***************************************************************************** - * Copyright (C) 1997-2004 + * Copyright (C) 1997-2005 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -55,7 +55,7 @@ int CountNewfiles(void) char ffile[PATH_MAX], group[13]; int count, i; - sprintf(ffile, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); + snprintf(ffile, PATH_MAX, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "a+")) != NULL) { Syslog('+', "Created new %s", ffile); @@ -65,17 +65,18 @@ int CountNewfiles(void) fwrite(&newfileshdr, sizeof(newfileshdr), 1, fil); memset(&newfiles, 0, sizeof(newfiles)); - sprintf(newfiles.Comment, "General newfiles announce"); - sprintf(newfiles.Area, "%s/var/mail/local/users", getenv("MBSE_ROOT")); - sprintf(newfiles.Origin, "%s", CFG.origin); - sprintf(newfiles.From, "Sysop"); - sprintf(newfiles.Too, "All"); - sprintf(newfiles.Subject, "New files found"); + snprintf(newfiles.Comment, 56, "General newfiles announce"); + snprintf(newfiles.Area, 51, "%s/var/mail/local/users", getenv("MBSE_ROOT")); + snprintf(newfiles.Origin, 51, "%s", CFG.origin); + snprintf(newfiles.From, 36, "Sysop"); + snprintf(newfiles.Too, 36, "All"); + snprintf(newfiles.Subject, 61, "New files found"); + snprintf(newfiles.Template, 15, "newfiles"); newfiles.Language = 'E'; newfiles.Active = TRUE; newfiles.HiAscii = TRUE; fwrite(&newfiles, sizeof(newfiles), 1, fil); - sprintf(group, "LOCAL"); + snprintf(group, 13, "LOCAL"); fwrite(&group, 13, 1, fil); memset(&group, 0, sizeof(group)); for (i = 1; i < CFG.new_groups; i++) @@ -111,8 +112,8 @@ int OpenNewfiles(void) long oldgroup; char group[13]; - sprintf(fnin, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); - sprintf(fnout, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); + snprintf(fnin, PATH_MAX, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); + snprintf(fnout, PATH_MAX, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); if ((fin = fopen(fnin, "r")) != NULL) { if ((fout = fopen(fnout, "w")) != NULL) { fread(&newfileshdr, sizeof(newfileshdr), 1, fin); @@ -146,7 +147,7 @@ int OpenNewfiles(void) memset(&newfiles, 0, sizeof(newfiles)); while (fread(&newfiles, oldsize, 1, fin) == 1) { if (!strlen(newfiles.Template)) { - sprintf(newfiles.Template, "newfiles"); + snprintf(newfiles.Template, 15, "newfiles"); NewUpdated = 1; } fwrite(&newfiles, sizeof(newfiles), 1, fout); @@ -187,8 +188,8 @@ void CloseNewfiles(int force) st_list *new = NULL, *tmp; int i; - sprintf(fin, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); - sprintf(fout,"%s/etc/newfiles.temp", getenv("MBSE_ROOT")); + snprintf(fin, PATH_MAX, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); + snprintf(fout, PATH_MAX, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); if (NewUpdated == 1) { if (force || (yes_no((char *)"Database is changed, save changes") == 1)) { @@ -239,15 +240,15 @@ int AppendNewfiles(void) char ffile[PATH_MAX], group[13]; int i; - sprintf(ffile, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); + snprintf(ffile, PATH_MAX, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); if ((fil = fopen(ffile, "a")) != NULL) { memset(&newfiles, 0, sizeof(newfiles)); /* * Fill in default values */ - sprintf(newfiles.From, "%s", CFG.sysop_name); + snprintf(newfiles.From, 36, "%s", CFG.sysop_name); newfiles.Language = 'E'; - sprintf(newfiles.Template, "newfiles"); + snprintf(newfiles.Template, 15, "newfiles"); strncpy(newfiles.Origin, CFG.origin, 50); fwrite(&newfiles, sizeof(newfiles), 1, fil); memset(&group, 0, 13); @@ -302,7 +303,7 @@ int EditNewRec(int Area) working(1, 0, 0); IsDoing("Edit Newfiles"); - sprintf(mfile, "%s/etc/ngroups.data", getenv("MBSE_ROOT")); + snprintf(mfile, PATH_MAX, "%s/etc/ngroups.data", getenv("MBSE_ROOT")); if ((fil = fopen(mfile, "r")) != NULL) { fread(&ngrouphdr, sizeof(ngrouphdr), 1, fil); @@ -313,7 +314,7 @@ int EditNewRec(int Area) sort_grlist(&fgr); } - sprintf(mfile, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); + snprintf(mfile, PATH_MAX, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); if ((fil = fopen(mfile, "r")) == NULL) { working(2, 0, 0); tidy_grlist(&fgr); @@ -353,7 +354,7 @@ int EditNewRec(int Area) show_str( 10,18,35, newfiles.From); show_str( 11,18,35, newfiles.Too); show_str( 12,18,60, newfiles.Subject); - sprintf(temp1, "%c", newfiles.Language); + snprintf(temp1, 2, "%c", newfiles.Language); show_str( 13,18,2, temp1); show_str( 14,18,14, newfiles.Template); show_str( 15,18,35, aka2str(newfiles.UseAka)); @@ -386,7 +387,7 @@ int EditNewRec(int Area) if (tmp->tagged) { i++; memset(&group, 0, 13); - sprintf(group, "%s", tmp->group); + snprintf(group, 13, "%s", tmp->group); fwrite(&group, 13, 1, fil); } @@ -462,7 +463,7 @@ void EditNewfiles(void) mbse_mvprintw( 5, 4, "12. NEWFILES REPORTS"); set_color(CYAN, BLACK); if (records != 0) { - sprintf(temp, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); working(1, 0, 0); if ((fil = fopen(temp, "r")) != NULL) { fread(&newfileshdr, sizeof(newfileshdr), 1, fil); @@ -482,7 +483,7 @@ void EditNewfiles(void) set_color(CYAN, BLACK); else set_color(LIGHTBLUE, BLACK); - sprintf(temp, "%3d. %-32s", o + i, newfiles.Comment); + snprintf(temp, 81, "%3d. %-32s", o + i, newfiles.Comment); temp[37] = 0; mbse_mvprintw(y, x, temp); y++; @@ -543,7 +544,7 @@ int new_doc(FILE *fp, FILE *toc, int page) FILE *wp, *ip, *no; int groups, i, j, nr = 0; - sprintf(temp, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); + snprintf(temp, PATH_MAX, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return page; @@ -566,7 +567,7 @@ int new_doc(FILE *fp, FILE *toc, int page) j = 0; } nr++; - sprintf(temp, "newfiles_%d.html", nr); + snprintf(temp, 81, "newfiles_%d.html", nr); fprintf(ip, "
  • Report %d %s
  • \n", temp, nr, newfiles.Comment); if ((wp = open_webdoc(temp, (char *)"Newfiles report", newfiles.Comment))) { fprintf(wp, "Main Back\n"); @@ -580,7 +581,7 @@ int new_doc(FILE *fp, FILE *toc, int page) add_webtable(wp, (char *)"From name", newfiles.From); add_webtable(wp, (char *)"To name", newfiles.Too); add_webtable(wp, (char *)"Subject", newfiles.Subject); - sprintf(temp, "%c", newfiles.Language); + snprintf(temp, 81, "%c", newfiles.Language); add_webtable(wp, (char *)"Language", temp); add_webtable(wp, (char *)"Aka to use", aka2str(newfiles.UseAka)); add_webtable(wp, (char *)"Active", getboolean(newfiles.Active));