Secured sprintf with snprintf
This commit is contained in:
parent
450b9fc276
commit
107b01699a
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Post Email message from temp file
|
* Purpose ...............: Post Email message from temp file
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -90,7 +90,7 @@ int postemail(FILE *fp, char *MailFrom, char *MailTo)
|
|||||||
temp = calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
temp = calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
||||||
|
|
||||||
rfcaddr = parserfcaddr(MailFrom);
|
rfcaddr = parserfcaddr(MailFrom);
|
||||||
sprintf(temp, "MAIL FROM:<%s@%s>\r\n", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
snprintf(temp, MAX_LINE_LENGTH, "MAIL FROM:<%s@%s>\r\n", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
||||||
Syslog('m', "%s", printable(temp, 0));
|
Syslog('m', "%s", printable(temp, 0));
|
||||||
if (smtp_cmd(temp, 250)) {
|
if (smtp_cmd(temp, 250)) {
|
||||||
WriteError("SMTP: refused FROM <%s@%s>", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
WriteError("SMTP: refused FROM <%s@%s>", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
||||||
@ -101,7 +101,7 @@ int postemail(FILE *fp, char *MailFrom, char *MailTo)
|
|||||||
tidyrfcaddr(rfcaddr);
|
tidyrfcaddr(rfcaddr);
|
||||||
|
|
||||||
rfcaddr = parserfcaddr(MailTo);
|
rfcaddr = parserfcaddr(MailTo);
|
||||||
sprintf(temp, "RCPT TO:<%s@%s>\r\n", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
snprintf(temp, MAX_LINE_LENGTH, "RCPT TO:<%s@%s>\r\n", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
||||||
Syslog('m', "%s", printable(temp, 0));
|
Syslog('m', "%s", printable(temp, 0));
|
||||||
if (smtp_cmd(temp, 250)) {
|
if (smtp_cmd(temp, 250)) {
|
||||||
WriteError("SMTP: refused TO <%s@%s>", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
WriteError("SMTP: refused TO <%s@%s>", MBSE_SS(rfcaddr.remainder), MBSE_SS(rfcaddr.target));
|
||||||
@ -128,7 +128,7 @@ int postemail(FILE *fp, char *MailFrom, char *MailTo)
|
|||||||
}
|
}
|
||||||
smtp_send(buf);
|
smtp_send(buf);
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp, " .\r\n");
|
snprintf(temp, MAX_LINE_LENGTH, " .\r\n");
|
||||||
smtp_send(temp);
|
smtp_send(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Post Netmail message from temp file
|
* Purpose ...............: Post Netmail message from temp file
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -67,7 +67,7 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
|
|||||||
int flags, int DoPing, unsigned int fzone, unsigned int tzone)
|
int flags, int DoPing, unsigned int fzone, unsigned int tzone)
|
||||||
{
|
{
|
||||||
char *p, *msgid = NULL, *reply = NULL, *flagstr = NULL;
|
char *p, *msgid = NULL, *reply = NULL, *flagstr = NULL;
|
||||||
char name[36], *buf, *l, *r, *q, System[36], ext[4];
|
char name[37], *buf, *l, *r, *q, System[37], ext[4];
|
||||||
int result = 1, email = FALSE, fmpt = 0, topt = 0;
|
int result = 1, email = FALSE, fmpt = 0, topt = 0;
|
||||||
faddr *ta, *ra;
|
faddr *ta, *ra;
|
||||||
fidoaddr na, routeto, Orig;
|
fidoaddr na, routeto, Orig;
|
||||||
@ -247,7 +247,7 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
|
|||||||
na.node = t->node;
|
na.node = t->node;
|
||||||
na.point = t->point;
|
na.point = t->point;
|
||||||
if (SearchFidonet(na.zone))
|
if (SearchFidonet(na.zone))
|
||||||
sprintf(na.domain, "%s", fidonet.domain);
|
snprintf(na.domain, 12, "%s", fidonet.domain);
|
||||||
|
|
||||||
switch(TrackMail(na, &routeto)) {
|
switch(TrackMail(na, &routeto)) {
|
||||||
case R_LOCAL:
|
case R_LOCAL:
|
||||||
@ -255,12 +255,12 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
|
|||||||
* Check the To: field.
|
* Check the To: field.
|
||||||
*/
|
*/
|
||||||
if (strchr(t->name, '@') != NULL) {
|
if (strchr(t->name, '@') != NULL) {
|
||||||
sprintf(name, "%s", strtok(t->name, "@"));
|
snprintf(name, 36, "%s", strtok(t->name, "@"));
|
||||||
sprintf(System, "%s", strtok(NULL, "\000"));
|
snprintf(System, 36, "%s", strtok(NULL, "\000"));
|
||||||
email = TRUE;
|
email = TRUE;
|
||||||
} else {
|
} else {
|
||||||
sprintf(name, "%s", t->name);
|
snprintf(name, 36, "%s", t->name);
|
||||||
sprintf(System, "%s", CFG.sysdomain);
|
snprintf(System, 36, "%s", CFG.sysdomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
@ -278,7 +278,7 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
|
|||||||
(strcasecmp(name, "postmaster") == 0) ||
|
(strcasecmp(name, "postmaster") == 0) ||
|
||||||
(strcasecmp(name, "coordinator") == 0)) {
|
(strcasecmp(name, "coordinator") == 0)) {
|
||||||
Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name);
|
Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name);
|
||||||
sprintf(name, "%s", CFG.sysop_name);
|
snprintf(name, 36, "%s", CFG.sysop_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -288,7 +288,7 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
|
|||||||
*/
|
*/
|
||||||
(void)noderecord(f);
|
(void)noderecord(f);
|
||||||
p = calloc(PATH_MAX, sizeof(char));
|
p = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(p, "%s/etc/service.data", getenv("MBSE_ROOT"));
|
snprintf(p, PATH_MAX -1, "%s/etc/service.data", getenv("MBSE_ROOT"));
|
||||||
if ((sfp = fopen(p, "r")) == NULL) {
|
if ((sfp = fopen(p, "r")) == NULL) {
|
||||||
WriteError("$Can't open %s", p);
|
WriteError("$Can't open %s", p);
|
||||||
} else {
|
} else {
|
||||||
@ -339,7 +339,7 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
|
|||||||
*/
|
*/
|
||||||
net_bad++;
|
net_bad++;
|
||||||
Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name);
|
Syslog('+', " Readdress from %s to %s", name, CFG.sysop_name);
|
||||||
sprintf(name, "%s", CFG.sysop_name);
|
snprintf(name, 36, "%s", CFG.sysop_name);
|
||||||
if (SearchUser(name)) {
|
if (SearchUser(name)) {
|
||||||
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
|
return storenet(f, t, mdate, flags, subject, msgid, reply, fp, flagstr);
|
||||||
} else {
|
} else {
|
||||||
@ -374,13 +374,13 @@ int postnetmail(FILE *fp, faddr *f, faddr *t, char *orig, char *subject, time_t
|
|||||||
|
|
||||||
memset(&ext, 0, sizeof(ext));
|
memset(&ext, 0, sizeof(ext));
|
||||||
if (nodes.PackNetmail)
|
if (nodes.PackNetmail)
|
||||||
sprintf(ext, (char *)"qqq");
|
snprintf(ext, 3, (char *)"qqq");
|
||||||
else if (nodes.Crash)
|
else if (nodes.Crash)
|
||||||
sprintf(ext, (char *)"ccc");
|
snprintf(ext, 3, (char *)"ccc");
|
||||||
else if (nodes.Hold)
|
else if (nodes.Hold)
|
||||||
sprintf(ext, (char *)"hhh");
|
snprintf(ext, 3, (char *)"hhh");
|
||||||
else
|
else
|
||||||
sprintf(ext, (char *)"nnn");
|
snprintf(ext, 3, (char *)"nnn");
|
||||||
|
|
||||||
if ((net = OpenPkt(Orig , routeto, (char *)ext)) == NULL) {
|
if ((net = OpenPkt(Orig , routeto, (char *)ext)) == NULL) {
|
||||||
net_bad++;
|
net_bad++;
|
||||||
|
@ -101,7 +101,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
/*
|
/*
|
||||||
* Now check the age of the .tic file.
|
* Now check the age of the .tic file.
|
||||||
*/
|
*/
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicName);
|
snprintf(Temp, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.TicName);
|
||||||
Fdate = file_time(Temp);
|
Fdate = file_time(Temp);
|
||||||
Age = (Now - Fdate) / 84400;
|
Age = (Now - Fdate) / 84400;
|
||||||
Syslog('+', "Orphaned tic age %d days", Age);
|
Syslog('+', "Orphaned tic age %d days", Age);
|
||||||
@ -115,7 +115,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
snprintf(Temp, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
crc = file_crc(Temp, CFG.slow_util && do_quiet);
|
crc = file_crc(Temp, CFG.slow_util && do_quiet);
|
||||||
TIC.FileSize = file_size(Temp);
|
TIC.FileSize = file_size(Temp);
|
||||||
TIC.FileDate = file_time(Temp);
|
TIC.FileDate = file_time(Temp);
|
||||||
@ -210,7 +210,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Magic_DeleteFile()) {
|
if (Magic_DeleteFile()) {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicName);
|
snprintf(temp1, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.TicName);
|
||||||
file_rm(temp1);
|
file_rm(temp1);
|
||||||
Syslog('+', "Deleted file %s", temp1);
|
Syslog('+', "Deleted file %s", temp1);
|
||||||
file_rm(Temp);
|
file_rm(Temp);
|
||||||
@ -238,7 +238,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
strcpy(TIC.BBSpath, CFG.ticout);
|
strcpy(TIC.BBSpath, CFG.ticout);
|
||||||
strcpy(TIC.BBSdesc, tic.Comment);
|
strcpy(TIC.BBSdesc, tic.Comment);
|
||||||
} else {
|
} else {
|
||||||
sprintf(Temp, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
snprintf(Temp, PATH_MAX -1, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
||||||
if ((fp = fopen(Temp, "r")) == NULL) {
|
if ((fp = fopen(Temp, "r")) == NULL) {
|
||||||
WriteError("Can't access fareas.data area: %ld", tic.FileArea);
|
WriteError("Can't access fareas.data area: %ld", tic.FileArea);
|
||||||
free(Temp);
|
free(Temp);
|
||||||
@ -282,7 +282,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((tic.DupCheck) && (check_dupe)) {
|
if ((tic.DupCheck) && (check_dupe)) {
|
||||||
sprintf(Temp, "%s%s", TIC.TicIn.Area, TIC.TicIn.Crc);
|
snprintf(Temp, PATH_MAX -1, "%s%s", TIC.TicIn.Area, TIC.TicIn.Crc);
|
||||||
crc2 = 0xffffffff;
|
crc2 = 0xffffffff;
|
||||||
crc2 = upd_crc32(Temp, crc2, strlen(Temp));
|
crc2 = upd_crc32(Temp, crc2, strlen(Temp));
|
||||||
if (CheckDupe(crc2, D_FILEECHO, CFG.tic_dupes)) {
|
if (CheckDupe(crc2, D_FILEECHO, CFG.tic_dupes)) {
|
||||||
@ -364,8 +364,8 @@ int ProcessTic(fa_list **sbl)
|
|||||||
* it's a passthru area.
|
* it's a passthru area.
|
||||||
*/
|
*/
|
||||||
if (((tic.SendOrg) && (MustRearc || strlen(tic.Banner))) || (!tic.FileArea)) {
|
if (((tic.SendOrg) && (MustRearc || strlen(tic.Banner))) || (!tic.FileArea)) {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
snprintf(temp1, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
sprintf(temp2, "%s/%s", CFG.ticout, TIC.TicIn.File);
|
snprintf(temp2, PATH_MAX -1, "%s/%s", CFG.ticout, TIC.TicIn.File);
|
||||||
if ((rc = file_cp(temp1, temp2) == 0)) {
|
if ((rc = file_cp(temp1, temp2) == 0)) {
|
||||||
TIC.SendOrg = TRUE;
|
TIC.SendOrg = TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -378,7 +378,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
/*
|
/*
|
||||||
* Check if there is a temp directory for the archive conversion.
|
* Check if there is a temp directory for the archive conversion.
|
||||||
*/
|
*/
|
||||||
sprintf(temp2, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
snprintf(temp2, PATH_MAX -1, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||||
if ((access(temp2, R_OK)) != 0) {
|
if ((access(temp2, R_OK)) != 0) {
|
||||||
if (mkdir(temp2, 0777)) {
|
if (mkdir(temp2, 0777)) {
|
||||||
WriteError("$Can't create %s", temp2);
|
WriteError("$Can't create %s", temp2);
|
||||||
@ -391,16 +391,16 @@ int ProcessTic(fa_list **sbl)
|
|||||||
/*
|
/*
|
||||||
* Check for stale FILE_ID.DIZ files
|
* Check for stale FILE_ID.DIZ files
|
||||||
*/
|
*/
|
||||||
sprintf(temp1, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
snprintf(temp1, PATH_MAX -1, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
if (!unlink(temp1))
|
if (!unlink(temp1))
|
||||||
Syslog('+', "Removed stale %s", temp1);
|
Syslog('+', "Removed stale %s", temp1);
|
||||||
sprintf(temp1, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
snprintf(temp1, PATH_MAX -1, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
||||||
if (!unlink(temp1))
|
if (!unlink(temp1))
|
||||||
Syslog('+', "Removed stale %s", temp1);
|
Syslog('+', "Removed stale %s", temp1);
|
||||||
sprintf(temp1, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
snprintf(temp1, PATH_MAX -1, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
if (!unlink(temp1))
|
if (!unlink(temp1))
|
||||||
Syslog('+', "Removed stale %s", temp1);
|
Syslog('+', "Removed stale %s", temp1);
|
||||||
sprintf(temp1, "%s/tmp/file_id.diz", getenv("MBSE_ROOT"));
|
snprintf(temp1, PATH_MAX -1, "%s/tmp/file_id.diz", getenv("MBSE_ROOT"));
|
||||||
if (!unlink(temp1))
|
if (!unlink(temp1))
|
||||||
Syslog('+', "Removed stale %s", temp1);
|
Syslog('+', "Removed stale %s", temp1);
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
if ((cmd == NULL) || (cmd == "")) {
|
if ((cmd == NULL) || (cmd == "")) {
|
||||||
Syslog('!', "No unarc command available");
|
Syslog('!', "No unarc command available");
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
snprintf(temp1, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||||
UnPacked = TRUE;
|
UnPacked = TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -451,8 +451,8 @@ int ProcessTic(fa_list **sbl)
|
|||||||
* whatever that is. This should catch single files
|
* whatever that is. This should catch single files
|
||||||
* with worms or other macro viri
|
* with worms or other macro viri
|
||||||
*/
|
*/
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
snprintf(temp1, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.TicIn.File);
|
snprintf(temp2, PATH_MAX -1, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), TIC.TicIn.File);
|
||||||
|
|
||||||
if ((rc = file_cp(temp1, temp2))) {
|
if ((rc = file_cp(temp1, temp2))) {
|
||||||
WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc));
|
WriteError("Can't copy %s to %s: %s", temp1, temp2, strerror(rc));
|
||||||
@ -461,7 +461,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(temp2, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
snprintf(temp2, PATH_MAX -1, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||||
if (chdir(temp2) != 0) {
|
if (chdir(temp2) != 0) {
|
||||||
WriteError("$Can't change to %s", temp2);
|
WriteError("$Can't change to %s", temp2);
|
||||||
free(Temp);
|
free(Temp);
|
||||||
@ -495,12 +495,12 @@ int ProcessTic(fa_list **sbl)
|
|||||||
|
|
||||||
if (tic.FileId && tic.FileArea && IsArchive) {
|
if (tic.FileId && tic.FileArea && IsArchive) {
|
||||||
if (UnPacked) {
|
if (UnPacked) {
|
||||||
sprintf(temp1, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
snprintf(temp1, PATH_MAX -1, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
sprintf(temp2, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
snprintf(temp2, PATH_MAX -1, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
if (file_cp(temp1, temp2) == 0) {
|
if (file_cp(temp1, temp2) == 0) {
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
snprintf(temp1, PATH_MAX -1, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
||||||
if (file_cp(temp1, temp2) == 0) {
|
if (file_cp(temp1, temp2) == 0) {
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
}
|
}
|
||||||
@ -514,13 +514,13 @@ int ProcessTic(fa_list **sbl)
|
|||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
WriteError("No unarc command available");
|
WriteError("No unarc command available");
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/tmp", getenv("MBSE_ROOT"));
|
snprintf(temp1, PATH_MAX -1, "%s/tmp", getenv("MBSE_ROOT"));
|
||||||
chdir(temp1);
|
chdir(temp1);
|
||||||
sprintf(temp1, "%s/%s FILE_ID.DIZ", TIC.Inbound, TIC.TicIn.File);
|
snprintf(temp1, PATH_MAX -1, "%s/%s FILE_ID.DIZ", TIC.Inbound, TIC.TicIn.File);
|
||||||
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/%s file_id.diz", TIC.Inbound, TIC.TicIn.File);
|
snprintf(temp1, PATH_MAX -1, "%s/%s file_id.diz", TIC.Inbound, TIC.TicIn.File);
|
||||||
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
if (execute_str(cmd, temp1, (char *)NULL, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
}
|
}
|
||||||
@ -584,7 +584,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
/*
|
/*
|
||||||
* Get new filesize for import and announce
|
* Get new filesize for import and announce
|
||||||
*/
|
*/
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
snprintf(temp1, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
||||||
TIC.FileSize = file_size(temp1);
|
TIC.FileSize = file_size(temp1);
|
||||||
T_File.Size = TIC.FileSize;
|
T_File.Size = TIC.FileSize;
|
||||||
T_File.SizeKb = TIC.FileSize / 1024;
|
T_File.SizeKb = TIC.FileSize / 1024;
|
||||||
@ -607,8 +607,8 @@ int ProcessTic(fa_list **sbl)
|
|||||||
if ((cmd == NULL) || (!strlen(cmd))) {
|
if ((cmd == NULL) || (!strlen(cmd))) {
|
||||||
Syslog('!', "No banner command for %s", archiver.name);
|
Syslog('!', "No banner command for %s", archiver.name);
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
snprintf(temp1, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
||||||
sprintf(Temp, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner);
|
snprintf(Temp, PATH_MAX -1, "%s/etc/%s", getenv("MBSE_ROOT"), tic.Banner);
|
||||||
if (execute_str(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) {
|
if (execute_str(cmd, temp1, (char *)NULL, Temp, (char *)"/dev/null", (char *)"/dev/null")) {
|
||||||
WriteError("Changing the banner failed");
|
WriteError("Changing the banner failed");
|
||||||
} else {
|
} else {
|
||||||
@ -629,7 +629,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
* If the file is converted, we set the date of the original
|
* If the file is converted, we set the date of the original
|
||||||
* received file as the file creation date.
|
* received file as the file creation date.
|
||||||
*/
|
*/
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.NewFile);
|
snprintf(Temp, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.NewFile);
|
||||||
if ((MustRearc || DidBanner) && CFG.ct_KeepDate) {
|
if ((MustRearc || DidBanner) && CFG.ct_KeepDate) {
|
||||||
if ((tic.Touch) && (tic.FileArea)) {
|
if ((tic.Touch) && (tic.FileArea)) {
|
||||||
ut.actime = mktime(localtime(&TIC.FileDate));
|
ut.actime = mktime(localtime(&TIC.FileDate));
|
||||||
@ -687,7 +687,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
* file in the inbound anymore so it can be
|
* file in the inbound anymore so it can be
|
||||||
* deleted.
|
* deleted.
|
||||||
*/
|
*/
|
||||||
sprintf(temp1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
snprintf(temp1, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.TicIn.File);
|
||||||
if (file_rm(temp1) == 0)
|
if (file_rm(temp1) == 0)
|
||||||
Syslog('f', "Deleted %s", temp1);
|
Syslog('f', "Deleted %s", temp1);
|
||||||
}
|
}
|
||||||
@ -703,7 +703,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
if (CFG.akavalid[i] && (tic.Aka.zone == CFG.aka[i].zone)) {
|
if (CFG.akavalid[i] && (tic.Aka.zone == CFG.aka[i].zone)) {
|
||||||
p_from = fido2faddr(CFG.aka[i]);
|
p_from = fido2faddr(CFG.aka[i]);
|
||||||
if (! in_list(p_from, sbl, TRUE)) {
|
if (! in_list(p_from, sbl, TRUE)) {
|
||||||
sprintf(sbe, "%u:%u/%u", CFG.aka[i].zone, CFG.aka[i].net, CFG.aka[i].node);
|
snprintf(sbe, 23, "%u:%u/%u", CFG.aka[i].zone, CFG.aka[i].net, CFG.aka[i].node);
|
||||||
fill_list(sbl, sbe, NULL);
|
fill_list(sbl, sbe, NULL);
|
||||||
}
|
}
|
||||||
tidy_faddr(p_from);
|
tidy_faddr(p_from);
|
||||||
@ -715,7 +715,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
*/
|
*/
|
||||||
for (tmpq = qal; tmpq; tmpq = tmpq->next) {
|
for (tmpq = qal; tmpq; tmpq = tmpq->next) {
|
||||||
if (tmpq->send) {
|
if (tmpq->send) {
|
||||||
sprintf(sbe, "%u:%u/%u", tmpq->aka.zone, tmpq->aka.net, tmpq->aka.node);
|
snprintf(sbe, 23, "%u:%u/%u", tmpq->aka.zone, tmpq->aka.net, tmpq->aka.node);
|
||||||
fill_list(sbl, sbe, NULL);
|
fill_list(sbl, sbe, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -739,7 +739,7 @@ int ProcessTic(fa_list **sbl)
|
|||||||
Magic_AdoptFile();
|
Magic_AdoptFile();
|
||||||
|
|
||||||
|
|
||||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicName);
|
snprintf(Temp, PATH_MAX -1, "%s/%s", TIC.Inbound, TIC.TicName);
|
||||||
unlink(Temp);
|
unlink(Temp);
|
||||||
|
|
||||||
free(Temp);
|
free(Temp);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Mail and file queue operations
|
* Purpose ...............: Mail and file queue operations
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -79,7 +79,7 @@ void flush_dir(char *ndir)
|
|||||||
fd_list *fdl = NULL;
|
fd_list *fdl = NULL;
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s/%s", CFG.out_queue, ndir);
|
snprintf(temp, PATH_MAX -1, "%s/%s", CFG.out_queue, ndir);
|
||||||
if (chdir(temp) == -1) {
|
if (chdir(temp) == -1) {
|
||||||
WriteError("$Error chdir to %s", temp);
|
WriteError("$Error chdir to %s", temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
@ -103,7 +103,7 @@ void flush_dir(char *ndir)
|
|||||||
nodenr.net = noden.net;
|
nodenr.net = noden.net;
|
||||||
nodenr.node = noden.node;
|
nodenr.node = noden.node;
|
||||||
nodenr.point = noden.point;
|
nodenr.point = noden.point;
|
||||||
sprintf(nodenr.domain, "%s", noden.domain);
|
snprintf(nodenr.domain, 12, "%s", noden.domain);
|
||||||
|
|
||||||
if (!SearchNode(nodenr)) {
|
if (!SearchNode(nodenr)) {
|
||||||
/*
|
/*
|
||||||
@ -185,27 +185,27 @@ void flush_dir(char *ndir)
|
|||||||
/*
|
/*
|
||||||
* Generate ARCfile name from the CRC of the ASCII string of the node address.
|
* Generate ARCfile name from the CRC of the ASCII string of the node address.
|
||||||
*/
|
*/
|
||||||
sprintf(arcfile, "%s/%08lx.%s0", nodes.Dir_out_path, StringCRC32(ascfnode(&noden, 0x1f)), ext);
|
snprintf(arcfile, PATH_MAX -1, "%s/%08lx.%s0", nodes.Dir_out_path, StringCRC32(ascfnode(&noden, 0x1f)), ext);
|
||||||
} else {
|
} else {
|
||||||
bestaka = bestaka_s(&noden);
|
bestaka = bestaka_s(&noden);
|
||||||
|
|
||||||
if (noden.point) {
|
if (noden.point) {
|
||||||
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
|
snprintf(arcfile, PATH_MAX -1, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
|
||||||
((bestaka->node) - (noden.node) + (noden.point)) & 0xffff, ext);
|
((bestaka->node) - (noden.node) + (noden.point)) & 0xffff, ext);
|
||||||
} else if (bestaka->point) {
|
} else if (bestaka->point) {
|
||||||
/*
|
/*
|
||||||
* Inserted the next code for if we are a point,
|
* Inserted the next code for if we are a point,
|
||||||
* I hope this is ARCmail 0.60 compliant. 21-May-1999
|
* I hope this is ARCmail 0.60 compliant. 21-May-1999
|
||||||
*/
|
*/
|
||||||
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
|
snprintf(arcfile, PATH_MAX -1, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
|
||||||
((bestaka->node) - (noden.node) - (bestaka->point)) & 0xffff, ext);
|
((bestaka->node) - (noden.node) - (bestaka->point)) & 0xffff, ext);
|
||||||
} else {
|
} else {
|
||||||
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
|
snprintf(arcfile, PATH_MAX -1, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
|
||||||
((bestaka->node) - (noden.node)) &0xffff, ext);
|
((bestaka->node) - (noden.node)) &0xffff, ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sprintf(arcfile, "%s", arcname(&noden, nodes.Aka[0].zone, nodes.ARCmailCompat));
|
snprintf(arcfile, PATH_MAX -1, "%s", arcname(&noden, nodes.Aka[0].zone, nodes.ARCmailCompat));
|
||||||
}
|
}
|
||||||
Syslog('P', "Arcmail file %s", arcfile);
|
Syslog('P', "Arcmail file %s", arcfile);
|
||||||
|
|
||||||
@ -214,9 +214,9 @@ void flush_dir(char *ndir)
|
|||||||
*/
|
*/
|
||||||
pktfile = calloc(PATH_MAX, sizeof(char));
|
pktfile = calloc(PATH_MAX, sizeof(char));
|
||||||
fname = calloc(PATH_MAX, sizeof(char));
|
fname = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(fname, "%s/mailpkt.qqq", temp);
|
snprintf(fname, PATH_MAX -1, "%s/mailpkt.qqq", temp);
|
||||||
if (access(fname, W_OK) == 0) {
|
if (access(fname, W_OK) == 0) {
|
||||||
sprintf(pktfile, "%s/%08lx.pkt", temp, sequencer());
|
snprintf(pktfile, PATH_MAX -1, "%s/%08lx.pkt", temp, sequencer());
|
||||||
if (rename(fname, pktfile)) {
|
if (rename(fname, pktfile)) {
|
||||||
WriteError("$Can't rename %s to %s", fname, pktfile);
|
WriteError("$Can't rename %s to %s", fname, pktfile);
|
||||||
} else {
|
} else {
|
||||||
@ -452,7 +452,7 @@ void flush_dir(char *ndir)
|
|||||||
flushed = TRUE;
|
flushed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(pktfile, "%s/%s", temp, fname);
|
snprintf(pktfile, PATH_MAX -1, "%s/%s", temp, fname);
|
||||||
|
|
||||||
if (strstr(fname, ".ddd"))
|
if (strstr(fname, ".ddd"))
|
||||||
flavor = 'd';
|
flavor = 'd';
|
||||||
@ -464,9 +464,9 @@ void flush_dir(char *ndir)
|
|||||||
flavor = 'o';
|
flavor = 'o';
|
||||||
|
|
||||||
if (nodes.Session_out == S_DIR) {
|
if (nodes.Session_out == S_DIR) {
|
||||||
sprintf(arcfile, "%s/%08lx.pkt", nodes.Dir_out_path, sequencer());
|
snprintf(arcfile, PATH_MAX -1, "%s/%08lx.pkt", nodes.Dir_out_path, sequencer());
|
||||||
} else {
|
} else {
|
||||||
sprintf(arcfile, "%s", pktname(&noden, flavor));
|
snprintf(arcfile, PATH_MAX -1, "%s", pktname(&noden, flavor));
|
||||||
}
|
}
|
||||||
Syslog('P', "Outfile: %s", arcfile);
|
Syslog('P', "Outfile: %s", arcfile);
|
||||||
Syslog('P', "Pktfile: %s", pktfile);
|
Syslog('P', "Pktfile: %s", pktfile);
|
||||||
@ -521,7 +521,7 @@ void flush_dir(char *ndir)
|
|||||||
* file, this tells the location of the file and what to do with
|
* file, this tells the location of the file and what to do with
|
||||||
* it after it is sent.
|
* it after it is sent.
|
||||||
*/
|
*/
|
||||||
sprintf(pktfile, "%s/.filelist", temp);
|
snprintf(pktfile, PATH_MAX -1, "%s/.filelist", temp);
|
||||||
if ((fp = fopen(pktfile, "r")) != NULL) {
|
if ((fp = fopen(pktfile, "r")) != NULL) {
|
||||||
|
|
||||||
Syslog('+', "Adding files for %s via %s", aka2str(nodenr), ascfnode(&noden, 0x1f));
|
Syslog('+', "Adding files for %s via %s", aka2str(nodenr), ascfnode(&noden, 0x1f));
|
||||||
@ -559,7 +559,7 @@ void flush_dir(char *ndir)
|
|||||||
if (nodes.Session_out == S_DIRECT) {
|
if (nodes.Session_out == S_DIRECT) {
|
||||||
attach(noden, p, mode, flavor);
|
attach(noden, p, mode, flavor);
|
||||||
} else if (nodes.Session_out == S_DIR) {
|
} else if (nodes.Session_out == S_DIR) {
|
||||||
sprintf(arcfile, "%s/%s", nodes.Dir_out_path, Basename(p));
|
snprintf(arcfile, PATH_MAX -1, "%s/%s", nodes.Dir_out_path, Basename(p));
|
||||||
if (mode == LEAVE) {
|
if (mode == LEAVE) {
|
||||||
/*
|
/*
|
||||||
* LEAVE file, so we copy this one.
|
* LEAVE file, so we copy this one.
|
||||||
@ -626,7 +626,7 @@ void flush_queue(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s/foobar", CFG.out_queue);
|
snprintf(temp, PATH_MAX -1, "%s/foobar", CFG.out_queue);
|
||||||
mkdirs(temp, 0750);
|
mkdirs(temp, 0750);
|
||||||
|
|
||||||
if ((dp = opendir(CFG.out_queue)) == 0) {
|
if ((dp = opendir(CFG.out_queue)) == 0) {
|
||||||
@ -641,7 +641,7 @@ void flush_queue(void)
|
|||||||
*/
|
*/
|
||||||
while ((de = readdir(dp))) {
|
while ((de = readdir(dp))) {
|
||||||
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
|
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
|
||||||
sprintf(temp, "%s/%s", CFG.out_queue, de->d_name);
|
snprintf(temp, PATH_MAX -1, "%s/%s", CFG.out_queue, de->d_name);
|
||||||
Syslog('p', "Queue directory %s", temp);
|
Syslog('p', "Queue directory %s", temp);
|
||||||
flush_dir(de->d_name);
|
flush_dir(de->d_name);
|
||||||
if (chdir(CFG.out_queue))
|
if (chdir(CFG.out_queue))
|
||||||
|
Reference in New Issue
Block a user