Secured sprintf with snprintf

This commit is contained in:
Michiel Broek 2005-08-29 10:29:22 +00:00
parent 00a70ffea9
commit e0fcfc4f59
6 changed files with 177 additions and 177 deletions

View File

@ -235,8 +235,8 @@ void OLR_TagArea()
Tagname = calloc(PATH_MAX, sizeof(char)); Tagname = calloc(PATH_MAX, sizeof(char));
buf = calloc(81, sizeof(char)); buf = calloc(81, sizeof(char));
sprintf(Msgname, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(Msgname, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
sprintf(Tagname, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(Tagname, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
clear(); clear();
/* Tag Offline Reader message areas */ /* Tag Offline Reader message areas */
@ -269,12 +269,12 @@ void OLR_TagArea()
if (msgs.Active && Access(exitinfo.Security, msgs.RDSec) && (!olrtagrec.Tagged) && strlen(msgs.QWKname)) { if (msgs.Active && Access(exitinfo.Security, msgs.RDSec) && (!olrtagrec.Tagged) && strlen(msgs.QWKname)) {
if ( (lines != 0) || (ignore) ) { if ( (lines != 0) || (ignore) ) {
lines--; lines--;
sprintf(msg, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name); snprintf(msg, 81, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name);
poutCR(CYAN, BLACK, msg); poutCR(CYAN, BLACK, msg);
} }
if (lines == 0) { if (lines == 0) {
/* More (Y/n/=) */ /* More (Y/n/=) */
sprintf(msg, "%s%c\x08", (char *) Language(61),Keystroke(61,0)); snprintf(msg, 81, "%s%c\x08", (char *) Language(61),Keystroke(61,0));
pout(WHITE, BLACK, msg); pout(WHITE, BLACK, msg);
alarm_on(); alarm_on();
input = toupper(Readkey()); input = toupper(Readkey());
@ -375,8 +375,8 @@ void OLR_UntagArea()
Tagname = calloc(PATH_MAX, sizeof(char)); Tagname = calloc(PATH_MAX, sizeof(char));
buf = calloc(81, sizeof(char)); buf = calloc(81, sizeof(char));
sprintf(Msgname, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(Msgname, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
sprintf(Tagname, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(Tagname, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
clear(); clear();
/* Untag Offline Reader message areas */ /* Untag Offline Reader message areas */
@ -409,12 +409,12 @@ void OLR_UntagArea()
if (msgs.Active && Access(exitinfo.Security, msgs.RDSec) && olrtagrec.Tagged && strlen(msgs.QWKname)) { if (msgs.Active && Access(exitinfo.Security, msgs.RDSec) && olrtagrec.Tagged && strlen(msgs.QWKname)) {
if ( (lines != 0) || (ignore) ) { if ( (lines != 0) || (ignore) ) {
lines--; lines--;
sprintf(msg, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name); snprintf(msg, 81, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name);
poutCR(CYAN, BLACK, msg); poutCR(CYAN, BLACK, msg);
} }
if (lines == 0) { if (lines == 0) {
/* More (Y/n/=) */ /* More (Y/n/=) */
sprintf(msg, "%s%c\x08", (char *) Language(61),Keystroke(61,0)); snprintf(msg, 81, "%s%c\x08", (char *) Language(61),Keystroke(61,0));
pout(WHITE, BLACK, msg); pout(WHITE, BLACK, msg);
alarm_on(); alarm_on();
input = toupper(Readkey()); input = toupper(Readkey());
@ -516,12 +516,12 @@ void New_Hdr()
clear(); clear();
colour(YELLOW, BLACK); colour(YELLOW, BLACK);
/* New or deleted mail areas at */ /* New or deleted mail areas at */
sprintf(temp, "%s%s", (char *) Language(364), CFG.bbs_name); snprintf(temp, 128, "%s%s", (char *) Language(364), CFG.bbs_name);
Center(temp); Center(temp);
Enter(1); Enter(1);
colour(WHITE, BLUE); colour(WHITE, BLUE);
/* Area State Type Description */ /* Area State Type Description */
sprintf(temp, "%-79s", (char *) Language(365)); snprintf(temp, 128, "%-79s", (char *) Language(365));
poutCR(WHITE, BLUE, temp); poutCR(WHITE, BLUE, temp);
free(temp); free(temp);
} }
@ -534,7 +534,7 @@ void New_Area(long Area)
char msg[81]; char msg[81];
/* New */ /* New */
sprintf(msg, "%4ld %s", Area, (char *)Language(391)); snprintf(msg, 81, "%4ld %s", Area, (char *)Language(391));
pout(LIGHTCYAN, BLACK, msg); pout(LIGHTCYAN, BLACK, msg);
switch (msgs.Type) { switch (msgs.Type) {
@ -560,7 +560,7 @@ void Old_Area(long Area)
char msg[81]; char msg[81];
/* Del */ /* Del */
sprintf(msg, "%4ld %s", Area, (char *)Language(397)); snprintf(msg, 81, "%4ld %s", Area, (char *)Language(397));
poutCR(LIGHTRED, BLACK, msg); poutCR(LIGHTRED, BLACK, msg);
} }
@ -579,8 +579,8 @@ void OLR_SyncTags()
Tagname = calloc(PATH_MAX, sizeof(char)); Tagname = calloc(PATH_MAX, sizeof(char));
Msgname = calloc(PATH_MAX, sizeof(char)); Msgname = calloc(PATH_MAX, sizeof(char));
sprintf(Tagname, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(Tagname, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Msgname, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(Msgname, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((fp = fopen(Tagname, "r+")) == NULL) { if ((fp = fopen(Tagname, "r+")) == NULL) {
@ -721,8 +721,8 @@ void OLR_ViewTags()
Tagname = calloc(PATH_MAX, sizeof(char)); Tagname = calloc(PATH_MAX, sizeof(char));
Msgname = calloc(PATH_MAX, sizeof(char)); Msgname = calloc(PATH_MAX, sizeof(char));
sprintf(Tagname, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(Tagname, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Msgname, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(Msgname, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((tf = fopen(Tagname, "r")) == NULL) { if ((tf = fopen(Tagname, "r")) == NULL) {
WriteError("$Can't open %s", Tagname); WriteError("$Can't open %s", Tagname);
@ -762,13 +762,13 @@ void OLR_ViewTags()
total = 0; total = 0;
if ( (lines != 0) || (ignore) ) { if ( (lines != 0) || (ignore) ) {
lines--; lines--;
sprintf(msg, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name); snprintf(msg, 81, "%-20.20s %-5ld %-5ld %s", msgs.QWKname, Area, total, msgs.Name);
PUTSTR(msg); PUTSTR(msg);
Enter(1); Enter(1);
} }
if (lines == 0) { if (lines == 0) {
/* More (Y/n/=) */ /* More (Y/n/=) */
sprintf(msg, "%s%c\x08", (char *) Language(61),Keystroke(61,0)); snprintf(msg, 81, "%s%c\x08", (char *) Language(61),Keystroke(61,0));
pout(WHITE, BLACK, msg); pout(WHITE, BLACK, msg);
alarm_on(); alarm_on();
input = toupper(Readkey()); input = toupper(Readkey());
@ -819,11 +819,11 @@ int OLR_Prescan()
check_popmail(exitinfo.Name, exitinfo.Password); check_popmail(exitinfo.Name, exitinfo.Password);
Temp = calloc(PATH_MAX, sizeof(char)); 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"));
mf = fopen(Temp, "r"); mf = fopen(Temp, "r");
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
sprintf(Temp, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(Temp, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
tf = fopen(Temp, "r"); tf = fopen(Temp, "r");
Total = TotalPersonal = Areas = 0; Total = TotalPersonal = Areas = 0;
@ -840,7 +840,7 @@ int OLR_Prescan()
if (Msg_Open(msgs.Base)) { if (Msg_Open(msgs.Base)) {
Areas++; Areas++;
Current = Personal = 0; Current = Personal = 0;
sprintf(msg, "%-20.20s %-41.41s ", msgs.QWKname, msgs.Name); snprintf(msg, 81, "%-20.20s %-41.41s ", msgs.QWKname, msgs.Name);
pout(LIGHTCYAN, BLACK, msg); pout(LIGHTCYAN, BLACK, msg);
memset(&LR, 0, sizeof(LR)); memset(&LR, 0, sizeof(LR));
@ -866,7 +866,7 @@ int OLR_Prescan()
} while (Msg_Next(&Number)); } while (Msg_Next(&Number));
} }
sprintf(msg, "%5lu %5lu", Current, Personal); snprintf(msg, 81, "%5lu %5lu", Current, Personal);
poutCR(LIGHTGREEN, BLACK, msg); poutCR(LIGHTGREEN, BLACK, msg);
Msg_Close(); Msg_Close();
} }
@ -877,7 +877,7 @@ int OLR_Prescan()
Enter(1); Enter(1);
/* Total messages found: */ /* Total messages found: */
sprintf(msg, "%s %lu", (char *)Language(338), Total); snprintf(msg, 81, "%s %lu", (char *)Language(338), Total);
pout(LIGHTBLUE, BLACK, msg); pout(LIGHTBLUE, BLACK, msg);
Enter(2); Enter(2);
@ -889,7 +889,7 @@ int OLR_Prescan()
} else { } else {
if (CFG.OLR_MaxMsgs != 0 && Total > CFG.OLR_MaxMsgs) { if (CFG.OLR_MaxMsgs != 0 && Total > CFG.OLR_MaxMsgs) {
/* Too much messages. Only the first will be packed! */ /* Too much messages. Only the first will be packed! */
sprintf(msg, "%s %d %s", (char *)Language(377), CFG.OLR_MaxMsgs, (char *)Language(411)); snprintf(msg, 81, "%s %d %s", (char *)Language(377), CFG.OLR_MaxMsgs, (char *)Language(411));
PUTCHAR('\007'); PUTCHAR('\007');
Enter(2); Enter(2);
Total = CFG.OLR_MaxMsgs; Total = CFG.OLR_MaxMsgs;
@ -927,7 +927,7 @@ void DrawBar(char *Pktname)
Enter(1); Enter(1);
/* Preparing packet */ /* Preparing packet */
sprintf(msg, "%s %s...", (char *)Language(445), Pktname); snprintf(msg, 81, "%s %s...", (char *)Language(445), Pktname);
pout(YELLOW, BLACK, msg); pout(YELLOW, BLACK, msg);
Enter(2); Enter(2);
poutCR(LIGHTGREEN, BLACK, (char *)"0%% 10%% 20%% 30%% 40%% 50%% 60%% 70%% 80%% 90%% 100%%"); poutCR(LIGHTGREEN, BLACK, (char *)"0%% 10%% 20%% 30%% 40%% 50%% 60%% 70%% 80%% 90%% 100%%");
@ -985,8 +985,8 @@ void OLR_Upload(void)
Home(); Home();
Enter(1); Enter(1);
sprintf(Dirpath, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name); snprintf(Dirpath, PATH_MAX, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Filename, "%s.NEW", CFG.bbsid); snprintf(Filename, 81, "%s.NEW", CFG.bbsid);
if (!RetVal) { if (!RetVal) {
RetVal = getfilecase(Dirpath, Filename); RetVal = getfilecase(Dirpath, Filename);
@ -994,7 +994,7 @@ void OLR_Upload(void)
} }
if (!RetVal) { if (!RetVal) {
sprintf(Filename, "%s.REP", CFG.bbsid); snprintf(Filename, 81, "%s.REP", CFG.bbsid);
RetVal = getfilecase(Dirpath, Filename); RetVal = getfilecase(Dirpath, Filename);
Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False"); Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False");
} }
@ -1014,7 +1014,7 @@ void OLR_Upload(void)
} }
tidy_upload(&up); tidy_upload(&up);
sprintf(File, "%s/%s", Dirpath, Filename); snprintf(File, PATH_MAX, "%s/%s", Dirpath, Filename);
Syslog('+', "Received OLR packet %s", File); Syslog('+', "Received OLR packet %s", File);
if ((Arc = GetFileType(File)) == NULL) { if ((Arc = GetFileType(File)) == NULL) {
@ -1028,7 +1028,7 @@ void OLR_Upload(void)
Syslog('m', "File type is %s", Arc); Syslog('m', "File type is %s", Arc);
sprintf(temp, "%s/etc/archiver.data", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) == NULL) if ((fp = fopen(temp, "r")) == NULL)
return; return;
@ -1055,7 +1055,7 @@ void OLR_Upload(void)
/* Unpacking archive */ /* Unpacking archive */
pout(CFG.TextColourF, CFG.TextColourB, (char *) Language(201)); pout(CFG.TextColourF, CFG.TextColourB, (char *) Language(201));
PUTCHAR(' '); PUTCHAR(' ');
sprintf(temp, "%s %s", archiver.funarc, File); snprintf(temp, PATH_MAX, "%s %s", archiver.funarc, File);
Syslog('m', "Unarc %s", temp); Syslog('m', "Unarc %s", temp);
colour(CFG.HiliteF, CFG.HiliteB); colour(CFG.HiliteF, CFG.HiliteB);
@ -1080,19 +1080,19 @@ void OLR_Upload(void)
* Check for BlueWave files, case insensitive. * Check for BlueWave files, case insensitive.
*/ */
RetVal = FALSE; RetVal = FALSE;
sprintf(Dirpath, "%s/%s", CFG.bbs_usersdir, exitinfo.Name); snprintf(Dirpath, PATH_MAX, "%s/%s", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Filename, "%s.UPL", CFG.bbsid); snprintf(Filename, 81, "%s.UPL", CFG.bbsid);
RetVal = getfilecase(Dirpath, Filename); RetVal = getfilecase(Dirpath, Filename);
Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False"); Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False");
if (!RetVal) { if (!RetVal) {
sprintf(Filename, "%s.REQ", CFG.bbsid); snprintf(Filename, 81, "%s.REQ", CFG.bbsid);
RetVal = getfilecase(Dirpath, Filename); RetVal = getfilecase(Dirpath, Filename);
Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False"); Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False");
} }
if (!RetVal) { if (!RetVal) {
sprintf(Filename, "%s.OLC", CFG.bbsid); snprintf(Filename, 81, "%s.OLC", CFG.bbsid);
RetVal = getfilecase(Dirpath, Filename); RetVal = getfilecase(Dirpath, Filename);
Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False"); Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False");
} }
@ -1108,7 +1108,7 @@ void OLR_Upload(void)
/* /*
* Check for QWK packet * Check for QWK packet
*/ */
sprintf(Filename, "%s.MSG", CFG.bbsid); snprintf(Filename, 81, "%s.MSG", CFG.bbsid);
RetVal = getfilecase(Dirpath, Filename); RetVal = getfilecase(Dirpath, Filename);
Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False"); Syslog('m', "%s RetVal=%s", Filename, RetVal?"True":"False");
@ -1181,12 +1181,12 @@ void OLR_DownBW()
tp = localtime(&Now); tp = localtime(&Now);
Syslog('+', "Preparing BlueWave packet"); Syslog('+', "Preparing BlueWave packet");
sprintf(Pktname, "%s%s", CFG.bbsid , Extensions[tp->tm_wday]); snprintf(Pktname, 32, "%s%s", CFG.bbsid , Extensions[tp->tm_wday]);
Syslog('m', "Packet name %s", Pktname); Syslog('m', "Packet name %s", Pktname);
sprintf(Work, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name); snprintf(Work, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
Syslog('m', "Work path %s", Work); Syslog('m', "Work path %s", Work);
sprintf(Temp, "%s/%s.INF", Work, CFG.bbsid); snprintf(Temp, PATH_MAX, "%s/%s.INF", Work, CFG.bbsid);
if ((fp = fopen(Temp, "w+")) == NULL) { if ((fp = fopen(Temp, "w+")) == NULL) {
WriteError("$Can't create %s", Temp); WriteError("$Can't create %s", Temp);
return; return;
@ -1232,7 +1232,7 @@ void OLR_DownBW()
return; return;
} }
sprintf(Temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(Temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mf = fopen(Temp, "r")) == NULL) { if ((mf = fopen(Temp, "r")) == NULL) {
WriteError("$Can't open %s", Temp); WriteError("$Can't open %s", Temp);
fclose(fp); fclose(fp);
@ -1240,7 +1240,7 @@ void OLR_DownBW()
} }
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
sprintf(Temp, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(Temp, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
if ((tf = fopen(Temp, "r")) == NULL) { if ((tf = fopen(Temp, "r")) == NULL) {
WriteError("$Can't open %s", Temp); WriteError("$Can't open %s", Temp);
fclose(fp); fclose(fp);
@ -1258,9 +1258,9 @@ void OLR_DownBW()
if (msgs.Active && Access(exitinfo.Security, msgs.RDSec) && strlen(msgs.QWKname)) { if (msgs.Active && Access(exitinfo.Security, msgs.RDSec) && strlen(msgs.QWKname)) {
memset(&AreaInf, 0, sizeof(AreaInf)); memset(&AreaInf, 0, sizeof(AreaInf));
sprintf((char *)AreaInf.areanum, "%lu", Area); snprintf((char *)AreaInf.areanum, 6, "%lu", Area);
strcpy((char *)AreaInf.echotag, msgs.QWKname); strncpy((char *)AreaInf.echotag, msgs.QWKname, 21);
strcpy((char *)AreaInf.title, msgs.Name); strncpy((char *)AreaInf.title, msgs.Name, 50);
if (olrtagrec.Tagged) { if (olrtagrec.Tagged) {
AreaInf.area_flags |= INF_SCANNING; AreaInf.area_flags |= INF_SCANNING;
RetVal = TRUE; RetVal = TRUE;
@ -1356,7 +1356,7 @@ void OLR_DownBW()
Enter(1); Enter(1);
PUTSTR((char *)Language(446)); PUTSTR((char *)Language(446));
PUTCHAR(' '); PUTCHAR(' ');
sprintf(Temp, "%s/etc/archiver.data", getenv("MBSE_ROOT")); snprintf(Temp, PATH_MAX, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
if ((af = fopen(Temp, "r")) != NULL) { if ((af = fopen(Temp, "r")) != NULL) {
fread(&archiverhdr, sizeof(archiverhdr), 1, af); fread(&archiverhdr, sizeof(archiverhdr), 1, af);
while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) { while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) {
@ -1364,16 +1364,16 @@ void OLR_DownBW()
Syslog('+', "Archiver %s", archiver.comment); Syslog('+', "Archiver %s", archiver.comment);
PUTSTR(archiver.comment); PUTSTR(archiver.comment);
PUTCHAR(' '); PUTCHAR(' ');
sprintf(Temp, "%s/%s.DAT", Work, CFG.bbsid); snprintf(Temp, PATH_MAX, "%s/%s.DAT", Work, CFG.bbsid);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
alarm_on(); alarm_on();
sprintf(Temp, "%s/%s.FTI", Work, CFG.bbsid); snprintf(Temp, PATH_MAX, "%s/%s.FTI", Work, CFG.bbsid);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
sprintf(Temp, "%s/%s.INF", Work, CFG.bbsid); snprintf(Temp, PATH_MAX, "%s/%s.INF", Work, CFG.bbsid);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
sprintf(Temp, "%s/%s.MIX", Work, CFG.bbsid); snprintf(Temp, PATH_MAX, "%s/%s.MIX", Work, CFG.bbsid);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
sprintf(Temp, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, Pktname); snprintf(Temp, PATH_MAX, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, Pktname);
rc = DownloadDirect(Temp, FALSE); rc = DownloadDirect(Temp, FALSE);
Syslog('m', "Download result %d", rc); Syslog('m', "Download result %d", rc);
unlink(Temp); unlink(Temp);
@ -1432,10 +1432,10 @@ void BlueWave_Fetch()
/* /*
* Process uploaded mail * Process uploaded mail
*/ */
sprintf(Dirpath, "%s/%s", CFG.bbs_usersdir, exitinfo.Name); snprintf(Dirpath, PATH_MAX, "%s/%s", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Filename, "%s.UPL", CFG.bbsid); snprintf(Filename, 81, "%s.UPL", CFG.bbsid);
if (getfilecase(Dirpath, Filename)) { if (getfilecase(Dirpath, Filename)) {
sprintf(temp, "%s/%s", Dirpath, Filename); snprintf(temp, PATH_MAX, "%s/%s", Dirpath, Filename);
up = fopen(temp, "r"); up = fopen(temp, "r");
} }
if (up != NULL) { if (up != NULL) {
@ -1494,7 +1494,7 @@ void BlueWave_Fetch()
Syslog('m', " File : %s", Upr.filename); Syslog('m', " File : %s", Upr.filename);
Syslog('m', " Tag : %s", Upr.echotag); Syslog('m', " Tag : %s", Upr.echotag);
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mf = fopen(temp, "r+")) != NULL) { if ((mf = fopen(temp, "r+")) != NULL) {
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
Found = FALSE; Found = FALSE;
@ -1546,7 +1546,7 @@ void BlueWave_Fetch()
dest.point = Upr.destpoint; dest.point = Upr.destpoint;
Add_Kludges(dest, FALSE, Upr.filename); Add_Kludges(dest, FALSE, Upr.filename);
Syslog('+', "Msg (%ld) to \"%s\", \"%s\", in %s", Msg.Id, Msg.To, Msg.Subject, msgs.QWKname); Syslog('+', "Msg (%ld) to \"%s\", \"%s\", in %s", Msg.Id, Msg.To, Msg.Subject, msgs.QWKname);
sprintf(temp, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, Upr.filename); snprintf(temp, PATH_MAX, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, Upr.filename);
unlink(temp); unlink(temp);
i++; i++;
fseek(mf, - (msgshdr.recsize + msgshdr.syssize), SEEK_CUR); fseek(mf, - (msgshdr.recsize + msgshdr.syssize), SEEK_CUR);
@ -1561,7 +1561,7 @@ void BlueWave_Fetch()
* Add quick mailscan info * Add quick mailscan info
*/ */
if (msgs.Type != LOCALMAIL) { if (msgs.Type != LOCALMAIL) {
sprintf(temp, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"), snprintf(temp, PATH_MAX, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"),
((msgs.Type == ECHOMAIL) || (msgs.Type == LIST))? "echo" : "net"); ((msgs.Type == ECHOMAIL) || (msgs.Type == LIST))? "echo" : "net");
if ((fp = fopen(temp, "a")) != NULL) { if ((fp = fopen(temp, "a")) != NULL) {
fprintf(fp, "%s %lu\n", msgs.Base, Msg.Id); fprintf(fp, "%s %lu\n", msgs.Base, Msg.Id);
@ -1573,7 +1573,7 @@ void BlueWave_Fetch()
} else { } else {
Enter(1); Enter(1);
/* No Write access to area */ /* No Write access to area */
sprintf(temp, "%s %s", (char *)Language(453), msgs.Name); snprintf(temp, PATH_MAX, "%s %s", (char *)Language(453), msgs.Name);
poutCR(LIGHTRED, BLACK, temp); poutCR(LIGHTRED, BLACK, temp);
WriteError("No Write Access to area %s", msgs.Name); WriteError("No Write Access to area %s", msgs.Name);
} }
@ -1585,7 +1585,7 @@ void BlueWave_Fetch()
Enter(1); Enter(1);
if (i) { if (i) {
/* Messages imported */ /* Messages imported */
sprintf(temp, "%d %s", i, (char *)Language(454)); snprintf(temp, PATH_MAX, "%d %s", i, (char *)Language(454));
poutCR(CFG.TextColourF, CFG.TextColourB, temp); poutCR(CFG.TextColourF, CFG.TextColourB, temp);
ReadExitinfo(); ReadExitinfo();
exitinfo.iPosted += i; exitinfo.iPosted += i;
@ -1593,7 +1593,7 @@ void BlueWave_Fetch()
do_mailout = TRUE; do_mailout = TRUE;
} }
fclose(up); fclose(up);
sprintf(temp, "%s/%s", Dirpath, Filename); snprintf(temp, PATH_MAX, "%s/%s", Dirpath, Filename);
unlink(temp); unlink(temp);
} }
@ -1605,9 +1605,9 @@ void BlueWave_Fetch()
/* /*
* Process offline configuration * Process offline configuration
*/ */
sprintf(Filename, "%s.OLC", CFG.bbsid); snprintf(Filename, 81, "%s.OLC", CFG.bbsid);
if (getfilecase(Dirpath, Filename)) { if (getfilecase(Dirpath, Filename)) {
sprintf(temp, "%s/%s", Dirpath, Filename); snprintf(temp, PATH_MAX, "%s/%s", Dirpath, Filename);
iol = fopen(temp, "r"); iol = fopen(temp, "r");
} }
if (iol != NULL) { if (iol != NULL) {
@ -1651,9 +1651,9 @@ void BlueWave_Fetch()
* There are areachanges, first reset all areas. * There are areachanges, first reset all areas.
*/ */
Syslog('m', "Resetting all areas"); Syslog('m', "Resetting all areas");
sprintf(temp, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(temp, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
if ((up = fopen(temp, "r+")) != NULL) { if ((up = fopen(temp, "r+")) != NULL) {
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mf = fopen(temp, "r")) != NULL) { if ((mf = fopen(temp, "r")) != NULL) {
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
while (fread(&olrtagrec, sizeof(olrtagrec), 1, up) == 0) { while (fread(&olrtagrec, sizeof(olrtagrec), 1, up) == 0) {
@ -1718,9 +1718,9 @@ void BlueWave_Fetch()
buffer++; buffer++;
if ((strncasecmp(buffer,"All",3)==0) || (strncasecmp(buffer,"Pers",4)==0)) { if ((strncasecmp(buffer,"All",3)==0) || (strncasecmp(buffer,"Pers",4)==0)) {
if (strlen(Echotag) > 0) { if (strlen(Echotag) > 0) {
sprintf(temp, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(temp, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
if ((up = fopen(temp, "r+")) != NULL) { if ((up = fopen(temp, "r+")) != NULL) {
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mf = fopen(temp, "r")) != NULL) { if ((mf = fopen(temp, "r")) != NULL) {
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
while (fread(&msgs, msgshdr.recsize, 1, mf) == 1) { while (fread(&msgs, msgshdr.recsize, 1, mf) == 1) {
@ -1746,10 +1746,10 @@ void BlueWave_Fetch()
} }
} }
fclose(iol); fclose(iol);
sprintf(temp, "%s/%s", Dirpath, Filename); snprintf(temp, PATH_MAX, "%s/%s", Dirpath, Filename);
unlink(temp); unlink(temp);
/* Message areas selected */ /* Message areas selected */
sprintf(temp, "%d %s", i, (char *)Language(456)); snprintf(temp, PATH_MAX, "%d %s", i, (char *)Language(456));
poutCR(CYAN, BLACK, temp); poutCR(CYAN, BLACK, temp);
Syslog('+', " %d active message areas.", i); Syslog('+', " %d active message areas.", i);
} }
@ -1757,7 +1757,7 @@ void BlueWave_Fetch()
/* /*
* Check for .REQ file. * Check for .REQ file.
*/ */
sprintf(Filename, "%s.REQ", CFG.bbsid); snprintf(Filename, 81, "%s.REQ", CFG.bbsid);
if (getfilecase(Dirpath, Filename)) { if (getfilecase(Dirpath, Filename)) {
tp = fopen(temp, "r"); tp = fopen(temp, "r");
} }
@ -1770,7 +1770,7 @@ void BlueWave_Fetch()
while (fread(&Req, sizeof(REQ_REC), 1, tp) == 1) { while (fread(&Req, sizeof(REQ_REC), 1, tp) == 1) {
Syslog('m', " File %s", Req.filename); Syslog('m', " File %s", Req.filename);
sprintf(temp, "%-12s ", Req.filename); snprintf(temp, PATH_MAX, "%-12s ", Req.filename);
pout(CFG.TextColourF, CFG.TextColourB, temp); pout(CFG.TextColourF, CFG.TextColourB, temp);
colour(CFG.HiliteF, CFG.HiliteB); colour(CFG.HiliteF, CFG.HiliteB);
@ -1803,17 +1803,17 @@ unsigned long BlueWave_PackArea(unsigned long ulLast, long Area)
Number = ulLast; Number = ulLast;
Temp = calloc(PATH_MAX, sizeof(char)); Temp = calloc(PATH_MAX, sizeof(char));
sprintf(Temp, "%s/%s/tmp/%s.FTI", CFG.bbs_usersdir, exitinfo.Name, CFG.bbsid); snprintf(Temp, PATH_MAX, "%s/%s/tmp/%s.FTI", CFG.bbs_usersdir, exitinfo.Name, CFG.bbsid);
fdfti = fopen(Temp, "a+"); fdfti = fopen(Temp, "a+");
sprintf(Temp, "%s/%s/tmp/%s.MIX", CFG.bbs_usersdir, exitinfo.Name, CFG.bbsid); snprintf(Temp, PATH_MAX, "%s/%s/tmp/%s.MIX", CFG.bbs_usersdir, exitinfo.Name, CFG.bbsid);
fdmix = fopen(Temp, "a+"); fdmix = fopen(Temp, "a+");
sprintf(Temp, "%s/%s/tmp/%s.DAT", CFG.bbs_usersdir, exitinfo.Name, CFG.bbsid); snprintf(Temp, PATH_MAX, "%s/%s/tmp/%s.DAT", CFG.bbs_usersdir, exitinfo.Name, CFG.bbsid);
fdm = fopen(Temp, "a+"); fdm = fopen(Temp, "a+");
memset(&Mix, 0, sizeof(MIX_REC)); memset(&Mix, 0, sizeof(MIX_REC));
sprintf((char *)Mix.areanum, "%lu", Area); snprintf((char *)Mix.areanum, 6, "%lu", Area);
Mix.msghptr = ftell(fdfti); Mix.msghptr = ftell(fdfti);
if ((fdfti != NULL) && (fdmix != NULL) && (fdm != NULL)) { if ((fdfti != NULL) && (fdmix != NULL) && (fdm != NULL)) {
@ -1847,7 +1847,7 @@ unsigned long BlueWave_PackArea(unsigned long ulLast, long Area)
Msg.Subject[sizeof(Fti.subject) - 1] = '\0'; Msg.Subject[sizeof(Fti.subject) - 1] = '\0';
strcpy((char *)Fti.subject, Msg.Subject); strcpy((char *)Fti.subject, Msg.Subject);
tp = localtime(&Msg.Written); tp = localtime(&Msg.Written);
sprintf((char *)Fti.date, "%2d %.3s %2d %2d:%02d:%02d", tp->tm_mday, snprintf((char *)Fti.date, 20, "%2d %.3s %2d %2d:%02d:%02d", tp->tm_mday,
(char *) Language(398 + tp->tm_mon), tp->tm_year, tp->tm_hour, tp->tm_min, tp->tm_sec); (char *) Language(398 + tp->tm_mon), tp->tm_year, tp->tm_hour, tp->tm_min, tp->tm_sec);
Fti.msgnum = Number; Fti.msgnum = Number;
Fti.msgptr = ftell(fdm); Fti.msgptr = ftell(fdm);
@ -1876,7 +1876,7 @@ unsigned long BlueWave_PackArea(unsigned long ulLast, long Area)
if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) { if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) {
BarWidth = (unsigned short)((Total * 61L) / TotalPack); BarWidth = (unsigned short)((Total * 61L) / TotalPack);
sprintf(msg, "\r%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"); snprintf(msg, 81, "\r%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
pout(CYAN, BLACK, msg); pout(CYAN, BLACK, msg);
} }
} while (Msg_Next(&Number)); } while (Msg_Next(&Number));
@ -1942,13 +1942,13 @@ void OLR_DownQWK(void)
tp = localtime(&Now); tp = localtime(&Now);
Syslog('+', "Preparing QWK packet"); Syslog('+', "Preparing QWK packet");
sprintf(Temp, "%s.QWK", CFG.bbsid); snprintf(Temp, PATH_MAX, "%s.QWK", CFG.bbsid);
sprintf(Pktname, "%s", tl(Temp)); snprintf(Pktname, 32, "%s", tl(Temp));
Syslog('m', "Packet name %s", Pktname); Syslog('m', "Packet name %s", Pktname);
sprintf(Work, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name); snprintf(Work, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
Syslog('m', "Work path %s", Work); Syslog('m', "Work path %s", Work);
sprintf(Temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(Temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mf = fopen(Temp, "r")) == NULL) { if ((mf = fopen(Temp, "r")) == NULL) {
WriteError("$Can't open %s", Temp); WriteError("$Can't open %s", Temp);
fclose(fp); fclose(fp);
@ -1958,7 +1958,7 @@ void OLR_DownQWK(void)
} }
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
sprintf(Temp, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(Temp, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
if ((tf = fopen(Temp, "r")) == NULL) { if ((tf = fopen(Temp, "r")) == NULL) {
WriteError("$Can't open %s", Temp); WriteError("$Can't open %s", Temp);
fclose(fp); fclose(fp);
@ -2001,7 +2001,7 @@ void OLR_DownQWK(void)
} }
} }
sprintf(Temp, "%s/CONTROL.DAT", Work); snprintf(Temp, PATH_MAX, "%s/CONTROL.DAT", Work);
if ((fp = fopen(Temp, "w+")) != NULL) { if ((fp = fopen(Temp, "w+")) != NULL) {
fprintf(fp, "%s\n", CFG.bbs_name); fprintf(fp, "%s\n", CFG.bbs_name);
fprintf(fp, "%s\n", CFG.location); fprintf(fp, "%s\n", CFG.location);
@ -2011,7 +2011,7 @@ void OLR_DownQWK(void)
fprintf(fp, "%02d-%02d-%04d,%02d:%02d:%02d\n", tp->tm_mday, tp->tm_mon+1, tp->tm_year+1900, fprintf(fp, "%02d-%02d-%04d,%02d:%02d:%02d\n", tp->tm_mday, tp->tm_mon+1, tp->tm_year+1900,
tp->tm_hour, tp->tm_min, tp->tm_sec); tp->tm_hour, tp->tm_min, tp->tm_sec);
sprintf(Temp, "%s", exitinfo.sUserName); snprintf(Temp, PATH_MAX, "%s", exitinfo.sUserName);
fprintf(fp, "%s\n", tu(Temp)); fprintf(fp, "%s\n", tu(Temp));
fprintf(fp, " \n"); fprintf(fp, " \n");
fprintf(fp, "0\n"); fprintf(fp, "0\n");
@ -2050,7 +2050,7 @@ void OLR_DownQWK(void)
fclose(fp); fclose(fp);
} }
sprintf(Temp, "%s/DOOR.ID", Work); snprintf(Temp, PATH_MAX, "%s/DOOR.ID", Work);
if ((fp = fopen(Temp, "w+")) != 0) { if ((fp = fopen(Temp, "w+")) != 0) {
fprintf(fp, "DOOR = MBSE BBS QWK\n"); fprintf(fp, "DOOR = MBSE BBS QWK\n");
fprintf(fp, "VERSION = %s\n", VERSION); fprintf(fp, "VERSION = %s\n", VERSION);
@ -2079,7 +2079,7 @@ void OLR_DownQWK(void)
/* Packing with */ /* Packing with */
PUTSTR((char *)Language(446)); PUTSTR((char *)Language(446));
PUTCHAR(' '); PUTCHAR(' ');
sprintf(Temp, "%s/etc/archiver.data", getenv("MBSE_ROOT")); snprintf(Temp, PATH_MAX, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
if ((af = fopen(Temp, "r")) != NULL) { if ((af = fopen(Temp, "r")) != NULL) {
fread(&archiverhdr, sizeof(archiverhdr), 1, af); fread(&archiverhdr, sizeof(archiverhdr), 1, af);
while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) { while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) {
@ -2087,26 +2087,26 @@ void OLR_DownQWK(void)
Syslog('+', "Archiver %s", archiver.comment); Syslog('+', "Archiver %s", archiver.comment);
PUTSTR(archiver.comment); PUTSTR(archiver.comment);
PUTCHAR(' '); PUTCHAR(' ');
sprintf(Temp, "%s/CONTROL.DAT", Work); snprintf(Temp, PATH_MAX, "%s/CONTROL.DAT", Work);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
alarm_on(); alarm_on();
sprintf(Temp, "%s/MESSAGES.DAT", Work); snprintf(Temp, PATH_MAX, "%s/MESSAGES.DAT", Work);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
for (tmp = mhl; tmp; tmp = tmp->next) { for (tmp = mhl; tmp; tmp = tmp->next) {
sprintf(Temp, "%s/%03ld.NDX", Work, tmp->Area); snprintf(Temp, PATH_MAX, "%s/%03ld.NDX", Work, tmp->Area);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
} }
sprintf(Temp, "%s/PERSONAL.NDX", Work); snprintf(Temp, PATH_MAX, "%s/PERSONAL.NDX", Work);
if (TotalPersonal) { if (TotalPersonal) {
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
} else } else
unlink(Temp); unlink(Temp);
sprintf(Temp, "%s/DOOR.ID", Work); snprintf(Temp, PATH_MAX, "%s/DOOR.ID", Work);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
sprintf(Temp, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, Pktname); snprintf(Temp, PATH_MAX, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, Pktname);
rc = DownloadDirect(Temp, FALSE); rc = DownloadDirect(Temp, FALSE);
Syslog('m', "Download result %d", rc); Syslog('m', "Download result %d", rc);
unlink(Temp); unlink(Temp);
@ -2159,10 +2159,10 @@ void QWK_Fetch()
otemp = calloc(PATH_MAX, sizeof(char)); otemp = calloc(PATH_MAX, sizeof(char));
nWidth = 78; nWidth = 78;
sprintf(Dirpath, "%s/%s", CFG.bbs_usersdir, exitinfo.Name); snprintf(Dirpath, PATH_MAX, "%s/%s", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Filename, "%s.MSG", CFG.bbsid); snprintf(Filename, 81, "%s.MSG", CFG.bbsid);
if (getfilecase(Dirpath, Filename)) { if (getfilecase(Dirpath, Filename)) {
sprintf(temp, "%s/%s", Dirpath, Filename); snprintf(temp, PATH_MAX, "%s/%s", Dirpath, Filename);
up = fopen(temp, "r"); up = fopen(temp, "r");
} }
@ -2196,15 +2196,15 @@ void QWK_Fetch()
Syslog('m', "To %s", tlcap(StripSpaces(Qwk.MsgTo, sizeof(Qwk.MsgTo)))); Syslog('m', "To %s", tlcap(StripSpaces(Qwk.MsgTo, sizeof(Qwk.MsgTo))));
Syslog('m', "From %s", tlcap(StripSpaces(Qwk.MsgFrom, sizeof(Qwk.MsgFrom)))); Syslog('m', "From %s", tlcap(StripSpaces(Qwk.MsgFrom, sizeof(Qwk.MsgFrom))));
Syslog('m', "Subject %s", StripSpaces(Qwk.MsgSubj, sizeof(Qwk.MsgSubj))); Syslog('m', "Subject %s", StripSpaces(Qwk.MsgSubj, sizeof(Qwk.MsgSubj)));
sprintf(Temp, "%s", StripSpaces(Qwk.Msgdate, sizeof(Qwk.Msgdate))); snprintf(Temp, 128, "%s", StripSpaces(Qwk.Msgdate, sizeof(Qwk.Msgdate)));
Syslog('m', "Date %s %s", Temp, StripSpaces(Qwk.Msgtime, sizeof(Qwk.Msgtime))); Syslog('m', "Date %s %s", Temp, StripSpaces(Qwk.Msgtime, sizeof(Qwk.Msgtime)));
if (strcmp("MBSEQWK", StripSpaces(Qwk.MsgTo, sizeof(Qwk.MsgTo))) == 0) { if (strcmp("MBSEQWK", StripSpaces(Qwk.MsgTo, sizeof(Qwk.MsgTo))) == 0) {
Syslog('m', "Command %s", StripSpaces(Qwk.MsgSubj, sizeof(Qwk.MsgSubj))); Syslog('m', "Command %s", StripSpaces(Qwk.MsgSubj, sizeof(Qwk.MsgSubj)));
sprintf(otemp, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(otemp, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
if ((op = fopen(otemp, "r+")) != NULL) { if ((op = fopen(otemp, "r+")) != NULL) {
sprintf(otemp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(otemp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mf = fopen(otemp, "r")) != NULL) { if ((mf = fopen(otemp, "r")) != NULL) {
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
fseek(mf, ((Area -1) * (msgshdr.recsize + msgshdr.syssize)) + msgshdr.hdrsize, SEEK_SET); fseek(mf, ((Area -1) * (msgshdr.recsize + msgshdr.syssize)) + msgshdr.hdrsize, SEEK_SET);
@ -2241,7 +2241,7 @@ void QWK_Fetch()
*/ */
Syslog('m', "Message"); Syslog('m', "Message");
HasTear = FALSE; HasTear = FALSE;
sprintf(otemp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(otemp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mf = fopen(otemp, "r+")) != NULL) { if ((mf = fopen(otemp, "r+")) != NULL) {
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
if ((fseek(mf, ((Area -1) * (msgshdr.recsize + msgshdr.syssize)) + msgshdr.hdrsize, SEEK_SET) == 0) && if ((fseek(mf, ((Area -1) * (msgshdr.recsize + msgshdr.syssize)) + msgshdr.hdrsize, SEEK_SET) == 0) &&
@ -2361,7 +2361,7 @@ void QWK_Fetch()
* Add quick mailscan info * Add quick mailscan info
*/ */
if (msgs.Type != LOCALMAIL) { if (msgs.Type != LOCALMAIL) {
sprintf(temp, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"), snprintf(temp, PATH_MAX, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"),
((msgs.Type == ECHOMAIL) || (msgs.Type == LIST))? "echo" : "net"); ((msgs.Type == ECHOMAIL) || (msgs.Type == LIST))? "echo" : "net");
if ((fp = fopen(temp, "a")) != NULL) { if ((fp = fopen(temp, "a")) != NULL) {
fprintf(fp, "%s %lu\n", msgs.Base, Msg.Id); fprintf(fp, "%s %lu\n", msgs.Base, Msg.Id);
@ -2390,14 +2390,14 @@ void QWK_Fetch()
Enter(1); Enter(1);
if (nPosted) { if (nPosted) {
/* Messages imported */ /* Messages imported */
sprintf(temp, "%d %s", nPosted, (char *)Language(454)); snprintf(temp, 81, "%d %s", nPosted, (char *)Language(454));
poutCR(CFG.TextColourF, CFG.TextColourB, temp); poutCR(CFG.TextColourF, CFG.TextColourB, temp);
ReadExitinfo(); ReadExitinfo();
exitinfo.iPosted += nPosted; exitinfo.iPosted += nPosted;
WriteExitinfo(); WriteExitinfo();
do_mailout = TRUE; do_mailout = TRUE;
} }
sprintf(temp, "%s/%s", Dirpath, Filename); snprintf(temp, PATH_MAX, "%s/%s", Dirpath, Filename);
Syslog('m', "Unlink %s rc=%d", temp, unlink(temp)); Syslog('m', "Unlink %s rc=%d", temp, unlink(temp));
free(temp); free(temp);
free(otemp); free(otemp);
@ -2462,19 +2462,19 @@ unsigned long QWK_PackArea(unsigned long ulLast, long Area)
Temp = calloc(PATH_MAX, sizeof(char)); Temp = calloc(PATH_MAX, sizeof(char));
Work = calloc(PATH_MAX, sizeof(char)); Work = calloc(PATH_MAX, sizeof(char));
sprintf(Work, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name); snprintf(Work, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Temp, "%s/%03ld.NDX", Work, Area); snprintf(Temp, PATH_MAX, "%s/%03ld.NDX", Work, Area);
fdi = fopen(Temp, "a+"); fdi = fopen(Temp, "a+");
sprintf(Temp, "%s/PERSONAL.NDX", Work); snprintf(Temp, PATH_MAX, "%s/PERSONAL.NDX", Work);
fdp = fopen(Temp, "a+"); fdp = fopen(Temp, "a+");
/* /*
* Open MESSAGES.DAT, if it doesn't exist, create it and write * Open MESSAGES.DAT, if it doesn't exist, create it and write
* the header. Then reopen the file in r/w mode. * the header. Then reopen the file in r/w mode.
*/ */
sprintf(Temp, "%s/MESSAGES.DAT", Work); snprintf(Temp, PATH_MAX, "%s/MESSAGES.DAT", Work);
if ((fdm = fopen (Temp, "r+")) == NULL) { if ((fdm = fopen (Temp, "r+")) == NULL) {
Syslog('m', "Creating new %s", Temp); Syslog('m', "Creating new %s", Temp);
fdm = fopen(Temp, "a+"); fdm = fopen(Temp, "a+");
@ -2488,7 +2488,7 @@ unsigned long QWK_PackArea(unsigned long ulLast, long Area)
memset(Temp, ' ', 54); memset(Temp, ' ', 54);
fwrite(Temp, 54, 1, fdm); fwrite(Temp, 54, 1, fdm);
fclose(fdm); fclose(fdm);
sprintf(Temp, "%s/MESSAGES.DAT", Work); snprintf(Temp, PATH_MAX, "%s/MESSAGES.DAT", Work);
fdm = fopen(Temp, "r+"); fdm = fopen(Temp, "r+");
} }
@ -2520,7 +2520,7 @@ unsigned long QWK_PackArea(unsigned long ulLast, long Area)
*/ */
Pos = ftell(fdm); Pos = ftell(fdm);
Blocks = (Pos / 128L) + 1L; Blocks = (Pos / 128L) + 1L;
sprintf(Temp, "%lu", Blocks); snprintf(Temp, 6, "%lu", Blocks);
in = atof(Temp); in = atof(Temp);
out = IEEToMSBIN(in); out = IEEToMSBIN(in);
fwrite(&out, sizeof(float), 1, fdi); fwrite(&out, sizeof(float), 1, fdi);
@ -2529,13 +2529,13 @@ unsigned long QWK_PackArea(unsigned long ulLast, long Area)
Total++; Total++;
memset(&Qwk, ' ', sizeof(Qwk)); memset(&Qwk, ' ', sizeof(Qwk));
sprintf(Temp, "%-*lu", (int)sizeof(Qwk.Msgnum), (long)Number); snprintf(Temp, 81, "%-*lu", (int)sizeof(Qwk.Msgnum), (long)Number);
Syslog('M', "Message %s", Temp); Syslog('M', "Message %s", Temp);
memcpy(Qwk.Msgnum, Temp, sizeof(Qwk.Msgnum)); memcpy(Qwk.Msgnum, Temp, sizeof(Qwk.Msgnum));
tp = localtime(&Msg.Written); tp = localtime(&Msg.Written);
sprintf(Temp, "%02d-%02d-%02d", tp->tm_mon+1, tp->tm_mday, tp->tm_year % 100); snprintf(Temp, 81, "%02d-%02d-%02d", tp->tm_mon+1, tp->tm_mday, tp->tm_year % 100);
memcpy(Qwk.Msgdate, Temp, sizeof(Qwk.Msgdate)); memcpy(Qwk.Msgdate, Temp, sizeof(Qwk.Msgdate));
sprintf(Temp, "%02d:%02d", tp->tm_hour, tp->tm_min); snprintf(Temp, 81, "%02d:%02d", tp->tm_hour, tp->tm_min);
memcpy(Qwk.Msgtime, Temp, sizeof(Qwk.Msgtime)); memcpy(Qwk.Msgtime, Temp, sizeof(Qwk.Msgtime));
Msg.From[sizeof(Qwk.MsgFrom) - 1] = '\0'; Msg.From[sizeof(Qwk.MsgFrom) - 1] = '\0';
memcpy(Qwk.MsgFrom, Msg.From, strlen(Msg.From)); memcpy(Qwk.MsgFrom, Msg.From, strlen(Msg.From));
@ -2562,7 +2562,7 @@ unsigned long QWK_PackArea(unsigned long ulLast, long Area)
Size += fwrite(Temp, (int)(128L - (Size % 128L)), 1, fdm); Size += fwrite(Temp, (int)(128L - (Size % 128L)), 1, fdm);
} }
sprintf(Qwk.Msgrecs, "%-*lu", (int)sizeof(Qwk.Msgrecs), (long)((ftell(fdm) - Pos) / 128L)); snprintf(Qwk.Msgrecs, 6, "%-*lu", (int)sizeof(Qwk.Msgrecs), (long)((ftell(fdm) - Pos) / 128L));
fseek(fdm, Pos, SEEK_SET); fseek(fdm, Pos, SEEK_SET);
fwrite(&Qwk, sizeof(Qwk), 1, fdm); fwrite(&Qwk, sizeof(Qwk), 1, fdm);
fseek(fdm, 0L, SEEK_END); fseek(fdm, 0L, SEEK_END);
@ -2573,7 +2573,7 @@ unsigned long QWK_PackArea(unsigned long ulLast, long Area)
if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) { if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) {
BarWidth = (unsigned short)((Total * 61L) / TotalPack); BarWidth = (unsigned short)((Total * 61L) / TotalPack);
PUTCHAR('\r'); PUTCHAR('\r');
sprintf(msg, "%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"); snprintf(msg, 81, "%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
pout(CYAN, BLACK, msg); pout(CYAN, BLACK, msg);
} }
} }
@ -2652,11 +2652,11 @@ void OLR_DownASCII(void)
tp = localtime(&Now); tp = localtime(&Now);
Syslog('+', "Preparing ASCII packet"); Syslog('+', "Preparing ASCII packet");
sprintf(Temp, "%s.MSG", CFG.bbsid); snprintf(Temp, PATH_MAX, "%s.MSG", CFG.bbsid);
sprintf(Pktname, "%s", tl(Temp)); snprintf(Pktname, 32, "%s", tl(Temp));
sprintf(Work, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name); snprintf(Work, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); snprintf(Temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mf = fopen(Temp, "r")) == NULL) { if ((mf = fopen(Temp, "r")) == NULL) {
WriteError("$Can't open %s", Temp); WriteError("$Can't open %s", Temp);
fclose(fp); fclose(fp);
@ -2664,7 +2664,7 @@ void OLR_DownASCII(void)
} }
fread(&msgshdr, sizeof(msgshdr), 1, mf); fread(&msgshdr, sizeof(msgshdr), 1, mf);
sprintf(Temp, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name); snprintf(Temp, PATH_MAX, "%s/%s/.olrtags", CFG.bbs_usersdir, exitinfo.Name);
if ((tf = fopen(Temp, "r")) == NULL) { if ((tf = fopen(Temp, "r")) == NULL) {
WriteError("$Can't open %s", Temp); WriteError("$Can't open %s", Temp);
fclose(fp); fclose(fp);
@ -2709,7 +2709,7 @@ void OLR_DownASCII(void)
/* Packing with */ /* Packing with */
PUTSTR((char *)Language(446)); PUTSTR((char *)Language(446));
PUTCHAR(' '); PUTCHAR(' ');
sprintf(Temp, "%s/etc/archiver.data", getenv("MBSE_ROOT")); snprintf(Temp, PATH_MAX, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
if ((af = fopen(Temp, "r")) != NULL) { if ((af = fopen(Temp, "r")) != NULL) {
fread(&archiverhdr, sizeof(archiverhdr), 1, af); fread(&archiverhdr, sizeof(archiverhdr), 1, af);
while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) { while (fread(&archiver, archiverhdr.recsize, 1, af) == 1) {
@ -2720,10 +2720,10 @@ void OLR_DownASCII(void)
alarm_on(); alarm_on();
for (tmp = mhl; tmp; tmp = tmp->next) { for (tmp = mhl; tmp; tmp = tmp->next) {
sprintf(Temp, "%s/%03ld.TXT", Work, tmp->Area); snprintf(Temp, PATH_MAX, "%s/%03ld.TXT", Work, tmp->Area);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
} }
sprintf(Temp, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, Pktname); snprintf(Temp, PATH_MAX, "%s/%s/%s", CFG.bbs_usersdir, exitinfo.Name, Pktname);
rc = DownloadDirect(Temp, FALSE); rc = DownloadDirect(Temp, FALSE);
unlink(Temp); unlink(Temp);
} }
@ -2771,9 +2771,9 @@ unsigned long ASCII_PackArea(unsigned long ulLast, long Area)
Temp = calloc(PATH_MAX, sizeof(char)); Temp = calloc(PATH_MAX, sizeof(char));
Work = calloc(PATH_MAX, sizeof(char)); Work = calloc(PATH_MAX, sizeof(char));
sprintf(Work, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name); snprintf(Work, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
sprintf(Temp, "%s/%03ld.TXT", Work, Area); snprintf(Temp, PATH_MAX, "%s/%03ld.TXT", Work, Area);
if ((fp = fopen(Temp, "a+")) != NULL) { if ((fp = fopen(Temp, "a+")) != NULL) {
if (Msg_Next(&Number)) { if (Msg_Next(&Number)) {
do { do {
@ -2818,7 +2818,7 @@ unsigned long ASCII_PackArea(unsigned long ulLast, long Area)
if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) { if (BarWidth != (unsigned short)((Total * 61L) / TotalPack)) {
BarWidth = (unsigned short)((Total * 61L) / TotalPack); BarWidth = (unsigned short)((Total * 61L) / TotalPack);
PUTCHAR('\r'); PUTCHAR('\r');
sprintf(msg, "%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"); snprintf(msg, 81, "%.*s", BarWidth, "ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
pout(CYAN, BLACK, msg); pout(CYAN, BLACK, msg);
} }
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Oneliner functions. * Purpose ...............: Oneliner functions.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -50,7 +50,7 @@ void Oneliner_Check()
char *sFileName; char *sFileName;
sFileName = calloc(PATH_MAX, sizeof(char)); sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName, "%s/etc/oneline.data", getenv("MBSE_ROOT")); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((pOneline = fopen(sFileName, "r")) == NULL) { if ((pOneline = fopen(sFileName, "r")) == NULL) {
if ((pOneline = fopen(sFileName, "w")) != NULL) { if ((pOneline = fopen(sFileName, "w")) != NULL) {
@ -80,7 +80,7 @@ void Oneliner_Add()
Oneliner_Check(); Oneliner_Check();
sFileName = calloc(PATH_MAX, sizeof(char)); sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT")); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((pOneline = fopen(sFileName, "a+")) == NULL) { if ((pOneline = fopen(sFileName, "a+")) == NULL) {
WriteError("Can't open file: %s", sFileName); WriteError("Can't open file: %s", sFileName);
@ -124,8 +124,8 @@ void Oneliner_Add()
Syslog('!', "User added oneliner:"); Syslog('!', "User added oneliner:");
Syslog('!', ol.Oneline); Syslog('!', ol.Oneline);
sprintf(ol.UserName,"%s", exitinfo.sUserName); snprintf(ol.UserName,36,"%s", exitinfo.sUserName);
sprintf(ol.DateOfEntry,"%02d-%02d-%04d",l_date->tm_mday,l_date->tm_mon+1,l_date->tm_year+1900); snprintf(ol.DateOfEntry,12,"%02d-%02d-%04d",l_date->tm_mday,l_date->tm_mon+1,l_date->tm_year+1900);
ol.Available = TRUE; ol.Available = TRUE;
fwrite(&ol, sizeof(ol), 1, pOneline); fwrite(&ol, sizeof(ol), 1, pOneline);
@ -197,7 +197,7 @@ char *Oneliner_Get()
* Get a random oneliner * Get a random oneliner
*/ */
sFileName = calloc(128, sizeof(char)); sFileName = calloc(128, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT")); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((pOneline = fopen(sFileName, "r+")) == NULL) { if ((pOneline = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName); WriteError("Can't open file: %s", sFileName);
@ -251,7 +251,7 @@ void Oneliner_List()
clear(); clear();
sFileName = calloc(PATH_MAX, sizeof(char)); sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT")); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((pOneline = fopen(sFileName, "r+")) == NULL) { if ((pOneline = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName); WriteError("Can't open file: %s", sFileName);
@ -272,23 +272,23 @@ void Oneliner_List()
while (fread(&ol, olhdr.recsize, 1, pOneline) == 1) { while (fread(&ol, olhdr.recsize, 1, pOneline) == 1) {
if ((SYSOP == TRUE) || (exitinfo.Security.level >= CFG.sysop_access)) { if ((SYSOP == TRUE) || (exitinfo.Security.level >= CFG.sysop_access)) {
sprintf(msg, "%2d", recno); snprintf(msg, 81, "%2d", recno);
pout(WHITE, BLACK, msg); pout(WHITE, BLACK, msg);
sprintf(msg, "%2d ", ol.Available); snprintf(msg, 81, "%2d ", ol.Available);
pout(LIGHTBLUE, BLACK, msg); pout(LIGHTBLUE, BLACK, msg);
pout(LIGHTCYAN, BLACK, ol.DateOfEntry); pout(LIGHTCYAN, BLACK, ol.DateOfEntry);
sprintf(msg, "%-15s ", ol.UserName); snprintf(msg, 81, "%-15s ", ol.UserName);
pout(CYAN, BLACK, msg); pout(CYAN, BLACK, msg);
sprintf(msg, "%-.48s", ol.Oneline); snprintf(msg, 81, "%-.48s", ol.Oneline);
poutCR(Colour, BLACK, msg); poutCR(Colour, BLACK, msg);
} else { } else {
sprintf(msg, "%2d ", recno); snprintf(msg, 81, "%2d ", recno);
pout(WHITE, BLACK, msg); pout(WHITE, BLACK, msg);
sprintf(msg, "%-.76s", ol.Oneline); snprintf(msg, 81, "%-.76s", ol.Oneline);
poutCR(Colour, BLACK, msg); poutCR(Colour, BLACK, msg);
} }
@ -313,7 +313,7 @@ void Oneliner_Show()
char *sFileName, msg[11]; char *sFileName, msg[11];
sFileName = calloc(PATH_MAX, sizeof(char)); sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT")); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((pOneline = fopen(sFileName, "r+")) == NULL) { if ((pOneline = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName); WriteError("Can't open file: %s", sFileName);
@ -334,7 +334,7 @@ void Oneliner_Show()
fread(&ol, olhdr.recsize, 1, pOneline); fread(&ol, olhdr.recsize, 1, pOneline);
Enter(1); Enter(1);
sprintf(msg, "%d ", recno); snprintf(msg, 11, "%d ", recno);
pout(WHITE, BLACK, msg); pout(WHITE, BLACK, msg);
pout(LIGHTRED, BLACK, ol.Oneline); pout(LIGHTRED, BLACK, ol.Oneline);
Enter(2); Enter(2);
@ -354,7 +354,7 @@ void Oneliner_Delete()
char srecno[7], *sFileName, stemp[50], sUser[36], msg[81]; char srecno[7], *sFileName, stemp[50], sUser[36], msg[81];
sFileName = calloc(PATH_MAX, sizeof(char)); sFileName = calloc(PATH_MAX, sizeof(char));
sprintf(sFileName,"%s/etc/oneline.data", getenv("MBSE_ROOT")); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
if ((pOneline = fopen(sFileName, "r+")) == NULL) { if ((pOneline = fopen(sFileName, "r+")) == NULL) {
WriteError("Can't open file: %s", sFileName); WriteError("Can't open file: %s", sFileName);
@ -398,16 +398,16 @@ void Oneliner_Delete()
fread(&ol, olhdr.recsize, 1, pOneline); fread(&ol, olhdr.recsize, 1, pOneline);
/* Convert Record Int to string, so we can print to logfiles */ /* Convert Record Int to string, so we can print to logfiles */
sprintf(stemp,"%d", nrecno); snprintf(stemp,50,"%d", nrecno);
/* Print UserName to String, so we can compare for deletion */ /* Print UserName to String, so we can compare for deletion */
sprintf(sUser,"%s", exitinfo.sUserName); snprintf(sUser,36,"%s", exitinfo.sUserName);
if ((strcmp(sUser, ol.UserName)) != 0) { if ((strcmp(sUser, ol.UserName)) != 0) {
if ((!SYSOP) && (exitinfo.Security.level < CFG.sysop_access)) { if ((!SYSOP) && (exitinfo.Security.level < CFG.sysop_access)) {
Enter(1); Enter(1);
/* Record *//* does not belong to you.*/ /* Record *//* does not belong to you.*/
sprintf(msg, "%s%s %s", (char *) Language(332), stemp, (char *) Language(333)); snprintf(msg, 81, "%s%s %s", (char *) Language(332), stemp, (char *) Language(333));
pout(LIGHTRED, BLACK, msg); pout(LIGHTRED, BLACK, msg);
Enter(2); Enter(2);
Syslog('!', "User tried to delete somebody else's record: %s", stemp); Syslog('!', "User tried to delete somebody else's record: %s", stemp);
@ -420,13 +420,13 @@ void Oneliner_Delete()
Enter(1); Enter(1);
if ((ol.Available ) == FALSE) { if ((ol.Available ) == FALSE) {
/* Record: %d already marked for deletion */ /* Record: %d already marked for deletion */
sprintf(msg, "%s%d %s", (char *) Language(332), nrecno, (char *) Language(334)); snprintf(msg, 81, "%s%d %s", (char *) Language(332), nrecno, (char *) Language(334));
pout(LIGHTRED, BLACK, msg); pout(LIGHTRED, BLACK, msg);
Syslog('!', "User tried to mark an already marked record: %s", stemp); Syslog('!', "User tried to mark an already marked record: %s", stemp);
} else { } else {
ol.Available = FALSE; ol.Available = FALSE;
/* Record *//* marked for deletion */ /* Record *//* marked for deletion */
sprintf(msg, "%s%d %s", (char *) Language(332), nrecno, (char *) Language(334)); snprintf(msg, 81, "%s%d %s", (char *) Language(332), nrecno, (char *) Language(334));
pout(LIGHTGREEN, BLACK, msg); pout(LIGHTGREEN, BLACK, msg);
Syslog('+', "User marked oneliner record for deletion: %s", stemp); Syslog('+', "User marked oneliner record for deletion: %s", stemp);
} }

View File

@ -5,7 +5,7 @@
* Todo ..................: Implement new config settings. * Todo ..................: Implement new config settings.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -98,7 +98,7 @@ void Page_Sysop(char *String)
Syslog('+', "Chat Reason: %s", temp); Syslog('+', "Chat Reason: %s", temp);
strcpy(Reason, temp); strcpy(Reason, temp);
} else { } else {
sprintf(Reason, "User want's to chat"); snprintf(Reason, 81, "User want's to chat");
} }
CFG.iMaxPageTimes--; CFG.iMaxPageTimes--;
@ -132,7 +132,7 @@ void Page_Sysop(char *String)
locate(16, ((80 - CFG.iPageLength) / 2 - 2) + 1); locate(16, ((80 - CFG.iPageLength) / 2 - 2) + 1);
sprintf(buf, "CPAG:2,%d,%s;", mypid, Reason); snprintf(buf, 128, "CPAG:2,%d,%s;", mypid, Reason);
if (socket_send(buf)) { if (socket_send(buf)) {
Syslog('+', "Failed to send message to mbtask"); Syslog('+', "Failed to send message to mbtask");
free(Reason); free(Reason);
@ -183,14 +183,14 @@ void Page_Sysop(char *String)
PUTCHAR(219); PUTCHAR(219);
sleep(1); sleep(1);
sprintf(buf, "CISC:1,%d", mypid); snprintf(buf, 128, "CISC:1,%d", mypid);
if (socket_send(buf) == 0) { if (socket_send(buf) == 0) {
strcpy(buf, socket_receive()); strcpy(buf, socket_receive());
if (strcmp(buf, "100:1,1;") == 0) { if (strcmp(buf, "100:1,1;") == 0) {
/* /*
* First cancel page request * First cancel page request
*/ */
sprintf(buf, "CCAN:1,%d;", mypid); snprintf(buf, 128, "CCAN:1,%d;", mypid);
socket_send(buf); socket_send(buf);
socket_receive(); socket_receive();
Syslog('+', "Sysop responded to paging request"); Syslog('+', "Sysop responded to paging request");
@ -204,7 +204,7 @@ void Page_Sysop(char *String)
/* /*
* Cancel page request * Cancel page request
*/ */
sprintf(buf, "CCAN:1,%d;", mypid); snprintf(buf, 128, "CCAN:1,%d;", mypid);
socket_send(buf); socket_send(buf);
strcpy(buf, socket_receive()); strcpy(buf, socket_receive());
} }
@ -247,7 +247,7 @@ void GetPageStr(char *sStr, int iMaxlen)
if (ch > 31 && ch < 127) { if (ch > 31 && ch < 127) {
if (iPos <= iMaxlen) { if (iPos <= iMaxlen) {
iPos++; iPos++;
sprintf(sStr, "%s%c", sStr, ch); snprintf(sStr, 4, "%s%c", sStr, ch);
PUTCHAR(ch); PUTCHAR(ch);
fflush(stdout); fflush(stdout);
} else } else
@ -275,7 +275,7 @@ void PageReason()
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
String = calloc(81, sizeof(char)); String = calloc(81, sizeof(char));
sprintf(temp, "%s/page.asc", CFG.bbs_txtfiles); snprintf(temp, PATH_MAX, "%s/page.asc", CFG.bbs_txtfiles);
if ((Page = fopen(temp, "r")) != NULL) { if ((Page = fopen(temp, "r")) != NULL) {
while (( fgets(String, 80 ,Page)) != NULL) while (( fgets(String, 80 ,Page)) != NULL)
@ -310,7 +310,7 @@ void PageReason()
if (!iFoundString) { if (!iFoundString) {
/* Sysop currently is not available ... please leave a comment */ /* Sysop currently is not available ... please leave a comment */
sprintf(String, "%s", (char *) Language(155)); snprintf(String, 81, "%s", (char *) Language(155));
locate(18, ((78 - strlen(String) ) / 2)); locate(18, ((78 - strlen(String) ) / 2));
pout(WHITE, BLACK, (char *)"["); pout(WHITE, BLACK, (char *)"[");
pout(LIGHTBLUE, BLACK, String); pout(LIGHTBLUE, BLACK, String);

View File

@ -4,7 +4,7 @@
* Purpose ...............: Product information * Purpose ...............: Product information
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -91,17 +91,17 @@ void cr(void)
wl(a); wl(a);
ls(a); ls(a);
sprintf(temp, "MBSE Bulletin Board System %s (%s-%s)", VERSION, OsName(), OsCPU()); snprintf(temp, 81, "MBSE Bulletin Board System %s (%s-%s)", VERSION, OsName(), OsCPU());
pout(YELLOW, BLACK, padleft(temp, 76, ' ')); pout(YELLOW, BLACK, padleft(temp, 76, ' '));
rs(a); rs(a);
wl(a); wl(a);
ls(a); ls(a);
sprintf(temp, "%s", COPYRIGHT); snprintf(temp, 81, "%s", COPYRIGHT);
pout(LIGHTCYAN, BLACK, padleft(temp, 76, ' ')); pout(LIGHTCYAN, BLACK, padleft(temp, 76, ' '));
rs(a); rs(a);
wl(a); wl(a);
ls(a); ls(a);
sprintf(temp, "Compiled on %s at %s", __DATE__, __TIME__); snprintf(temp, 81, "Compiled on %s at %s", __DATE__, __TIME__);
pout(LIGHTRED, BLACK, padleft(temp, 76, ' ')); pout(LIGHTRED, BLACK, padleft(temp, 76, ' '));
rs(a); rs(a);
wl(a); wl(a);

View File

@ -4,7 +4,7 @@
* Purpose ...............: POP3 client * Purpose ...............: POP3 client
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -57,11 +57,11 @@ void retr_msg(int msgnum)
int Header; int Header;
unsigned long crc = -1; unsigned long crc = -1;
sprintf(temp, "RETR %d\r\n", msgnum); snprintf(temp, 81, "RETR %d\r\n", msgnum);
if (pop3_cmd(temp) == 0) { if (pop3_cmd(temp) == 0) {
Msg_New(); Msg_New();
Header = TRUE; Header = TRUE;
sprintf(temp, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name); snprintf(temp, PATH_MAX, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
base = xstrcpy(temp); base = xstrcpy(temp);
Open_Msgbase(base, 'w'); Open_Msgbase(base, 'w');
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60); Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
@ -78,17 +78,17 @@ void retr_msg(int msgnum)
if (strncmp(p, "To: ", 4) == 0) { if (strncmp(p, "To: ", 4) == 0) {
if (strlen(p) > 104) if (strlen(p) > 104)
p[104] = '\0'; p[104] = '\0';
sprintf(Msg.To, "%s", p+4); snprintf(Msg.To, 101, "%s", p+4);
} }
if (strncmp(p, "From: ", 6) == 0) { if (strncmp(p, "From: ", 6) == 0) {
if (strlen(p) > 106) if (strlen(p) > 106)
p[106] = '\0'; p[106] = '\0';
sprintf(Msg.From, "%s", p+6); snprintf(Msg.From, 101, "%s", p+6);
} }
if (strncmp(p, "Subject: ", 9) == 0) { if (strncmp(p, "Subject: ", 9) == 0) {
if (strlen(p) > 109) if (strlen(p) > 109)
p[109] = '\0'; p[109] = '\0';
sprintf(Msg.Subject, "%s", p+9); snprintf(Msg.Subject, 101, "%s", p+9);
mbse_CleanSubject(Msg.Subject); mbse_CleanSubject(Msg.Subject);
} }
if (strncmp(p, "Date: ", 6) == 0) if (strncmp(p, "Date: ", 6) == 0)
@ -102,7 +102,7 @@ void retr_msg(int msgnum)
if (strlen(p) == 0) { if (strlen(p) == 0) {
Header = FALSE; Header = FALSE;
} else { } else {
sprintf(temp, "\001%s", p); snprintf(temp, PATH_MAX, "\001%s", p);
MsgText_Add2(temp); MsgText_Add2(temp);
} }
} else { } else {
@ -114,7 +114,7 @@ void retr_msg(int msgnum)
Msg_UnLock(); Msg_UnLock();
Close_Msgbase(base); Close_Msgbase(base);
free(base); free(base);
sprintf(temp, "DELE %d\r\n", msgnum); snprintf(temp, 81, "DELE %d\r\n", msgnum);
pop3_cmd(temp); pop3_cmd(temp);
} else { } else {
WriteError("POP3: Can't retrieve message %d", msgnum); WriteError("POP3: Can't retrieve message %d", msgnum);
@ -142,16 +142,16 @@ void check_popmail(char *user, char *pass)
} }
if (CFG.UsePopDomain) if (CFG.UsePopDomain)
sprintf(temp, "USER %s@%s\r\n", user, CFG.sysdomain); snprintf(temp, 128, "USER %s@%s\r\n", user, CFG.sysdomain);
else else
sprintf(temp, "USER %s\r\n", user); snprintf(temp, 128, "USER %s\r\n", user);
if (pop3_cmd(temp)) { if (pop3_cmd(temp)) {
error_popmail((char *)"You have no email box"); error_popmail((char *)"You have no email box");
return; return;
} }
sprintf(temp, "PASS %s\r\n", pass); snprintf(temp, 128, "PASS %s\r\n", pass);
if (pop3_cmd(temp)) { if (pop3_cmd(temp)) {
error_popmail((char *)"Wrong email password, reset your password"); error_popmail((char *)"Wrong email password, reset your password");
return; return;
@ -186,7 +186,7 @@ void check_popmail(char *user, char *pass)
* Show progress * Show progress
*/ */
PUTCHAR('\r'); PUTCHAR('\r');
sprintf(temp, "Fetching message %02d/%02d, total %d bytes", msgnum, tmsgs, size); snprintf(temp, 128, "Fetching message %02d/%02d, total %d bytes", msgnum, tmsgs, size);
pout(color, BLACK, temp); pout(color, BLACK, temp);
if (color < WHITE) if (color < WHITE)
color++; color++;

View File

@ -4,7 +4,7 @@
* Purpose ...............: Edit message signature. * Purpose ...............: Edit message signature.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2004 * Copyright (C) 1997-2005
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -115,7 +115,7 @@ int loadsignature(void)
int i; int i;
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name); snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
if ((fp = fopen(temp, "r")) == NULL) { if ((fp = fopen(temp, "r")) == NULL) {
WriteError("$Can't load %s", temp); WriteError("$Can't load %s", temp);
@ -142,7 +142,7 @@ int loadsignature(void)
toprow(); toprow();
for (i = 0; i < MAXSIGLINES; i++) { for (i = 0; i < MAXSIGLINES; i++) {
sprintf(temp, "%d:", i+1); snprintf(temp, 80, "%d:", i+1);
pout(LIGHTRED, BLACK, temp); pout(LIGHTRED, BLACK, temp);
poutCR(CFG.MoreF, CFG.MoreB, sLiNE[i]); poutCR(CFG.MoreF, CFG.MoreB, sLiNE[i]);
} }
@ -164,7 +164,7 @@ int editsignature(void)
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
temp1 = calloc(PATH_MAX, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name); snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
while (TRUE) { while (TRUE) {
Enter(1); Enter(1);
@ -193,7 +193,7 @@ int editsignature(void)
} else if (i == Keystroke(114, 2)) { } else if (i == Keystroke(114, 2)) {
Enter(1); Enter(1);
/* Edit which line: */ /* Edit which line: */
sprintf(temp, " %s", (char *) Language(118)); snprintf(temp, 80, " %s", (char *) Language(118));
pout(CFG.HiliteF, CFG.HiliteB, temp); pout(CFG.HiliteF, CFG.HiliteB, temp);
colour(CFG.InputColourF, CFG.InputColourB); colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(temp, 3); GetstrC(temp, 3);
@ -210,7 +210,7 @@ int editsignature(void)
} }
x = strlen(sLiNE[i-1]); x = strlen(sLiNE[i-1]);
sprintf(temp, "%d:", i); snprintf(temp, 80, "%d:", i);
pout(LIGHTRED, BLACK, temp); pout(LIGHTRED, BLACK, temp);
pout(CFG.InputColourF, CFG.InputColourB, sLiNE[i-1]); pout(CFG.InputColourF, CFG.InputColourB, sLiNE[i-1]);
GetstrP(sLiNE[i-1], LENSIGLINES-1, x); GetstrP(sLiNE[i-1], LENSIGLINES-1, x);
@ -219,7 +219,7 @@ int editsignature(void)
/* List lines */ /* List lines */
toprow(); toprow();
for (i = 0; i < MAXSIGLINES; i++) { for (i = 0; i < MAXSIGLINES; i++) {
sprintf(temp, "%d:", i+1); snprintf(temp, 80, "%d:", i+1);
pout(LIGHTRED, BLACK, temp); pout(LIGHTRED, BLACK, temp);
poutCR(CFG.MoreF, CFG.MoreB, sLiNE[i]); poutCR(CFG.MoreF, CFG.MoreB, sLiNE[i]);
} }
@ -231,7 +231,7 @@ int editsignature(void)
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(340)); pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(340));
/* Open TextFile for Writing NextUser Info */ /* Open TextFile for Writing NextUser Info */
sprintf(temp, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name); snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
if ((fp = fopen(temp, "w")) == NULL) { if ((fp = fopen(temp, "w")) == NULL) {
WriteError("$Can't open %s", temp); WriteError("$Can't open %s", temp);
free(temp); free(temp);
@ -271,7 +271,7 @@ int editsignature(void)
Enter(1); Enter(1);
/* Line reads: */ /* Line reads: */
poutCR(CFG.MoreF, CFG.MoreB, (char *) Language(186)); poutCR(CFG.MoreF, CFG.MoreB, (char *) Language(186));
sprintf(temp, "%d:%s", i, sLiNE[i-1]); snprintf(temp, 81, "%d:%s", i, sLiNE[i-1]);
poutCR(CFG.MoreF, CFG.MoreB, temp); poutCR(CFG.MoreF, CFG.MoreB, temp);
Enter(1); Enter(1);