Secured sprintf with snprintf
This commit is contained in:
parent
1c8719c1de
commit
e8eabe9f46
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Announce new files and FileFind
|
* Purpose ...............: Announce new files and FileFind
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:2801/16
|
* Michiel Broek FIDO: 2:2801/16
|
||||||
* Beekmansbos 10 Internet: mbroek@ux123.pttnwb.nl
|
* Beekmansbos 10 Internet: mbroek@ux123.pttnwb.nl
|
||||||
@ -75,8 +75,8 @@ void fill_grlist(gr_list **fdp, char *groupname, char *echoname)
|
|||||||
*/
|
*/
|
||||||
tmp = (gr_list *)malloc(sizeof(gr_list));
|
tmp = (gr_list *)malloc(sizeof(gr_list));
|
||||||
tmp->next = *fdp;
|
tmp->next = *fdp;
|
||||||
sprintf(tmp->group, "%s", groupname);
|
snprintf(tmp->group, 13, "%s", groupname);
|
||||||
sprintf(tmp->echo, "%s", echoname);
|
snprintf(tmp->echo, 21, "%s", echoname);
|
||||||
tmp->count = 1;
|
tmp->count = 1;
|
||||||
*fdp = tmp;
|
*fdp = tmp;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: MBSE BBS Mail Gate
|
* Purpose ...............: MBSE BBS Mail Gate
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -45,7 +45,7 @@ void hash_update_n(unsigned long *id, unsigned long mod)
|
|||||||
{
|
{
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
sprintf(buf,"%030lu",mod);
|
snprintf(buf,32, "%030lu",mod);
|
||||||
*id ^= lh_strhash(buf);
|
*id ^= lh_strhash(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Hatch files
|
* Purpose ...............: Hatch files
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -69,7 +69,7 @@ void Hatch()
|
|||||||
LastDay++;
|
LastDay++;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(temp, "%s/etc/hatch.data", getenv("MBSE_ROOT"));
|
snprintf(temp, PATH_MAX, "%s/etc/hatch.data", getenv("MBSE_ROOT"));
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
if ((fp = fopen(temp, "r")) == NULL) {
|
||||||
WriteError("$Can't open %s", temp);
|
WriteError("$Can't open %s", temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
@ -85,7 +85,7 @@ void Hatch()
|
|||||||
HatchToday = TRUE;
|
HatchToday = TRUE;
|
||||||
if ((hatch.Month[Tm->tm_mday -1]) || (hatch.Month[31] && (LastDay == Tm->tm_mday)))
|
if ((hatch.Month[Tm->tm_mday -1]) || (hatch.Month[31] && (LastDay == Tm->tm_mday)))
|
||||||
HatchToday = TRUE;
|
HatchToday = TRUE;
|
||||||
sprintf(temp, "%s", hatch.Spec);
|
snprintf(temp, PATH_MAX, "%s", hatch.Spec);
|
||||||
|
|
||||||
if (HatchToday)
|
if (HatchToday)
|
||||||
CheckHatch(temp);
|
CheckHatch(temp);
|
||||||
@ -132,7 +132,7 @@ int CheckHatch(char *temp)
|
|||||||
if (re_exec(de->d_name)) {
|
if (re_exec(de->d_name)) {
|
||||||
hatched = TRUE;
|
hatched = TRUE;
|
||||||
Syslog('+', "Hatch \"%s\" in area %s", de->d_name, hatch.Name);
|
Syslog('+', "Hatch \"%s\" in area %s", de->d_name, hatch.Name);
|
||||||
sprintf(tf, "%s/%s", CFG.pinbound, MakeTicName());
|
snprintf(tf, PATH_MAX, "%s/%s", CFG.pinbound, MakeTicName());
|
||||||
|
|
||||||
if ((Tf = fopen(tf, "a+")) == NULL) {
|
if ((Tf = fopen(tf, "a+")) == NULL) {
|
||||||
WriteError("Can't create %s", tf);
|
WriteError("Can't create %s", tf);
|
||||||
@ -153,7 +153,7 @@ int CheckHatch(char *temp)
|
|||||||
if (strlen(hatch.Magic))
|
if (strlen(hatch.Magic))
|
||||||
fprintf(Tf, "Magic %s\r\n", hatch.Magic);
|
fprintf(Tf, "Magic %s\r\n", hatch.Magic);
|
||||||
temp2 = calloc(strlen(de->d_name) + 1, sizeof(char));
|
temp2 = calloc(strlen(de->d_name) + 1, sizeof(char));
|
||||||
sprintf(temp2, "%s", de->d_name);
|
snprintf(temp2, strlen(de->d_name) + 1, "%s", de->d_name);
|
||||||
name_mangle(temp2);
|
name_mangle(temp2);
|
||||||
fprintf(Tf, "File %s\r\n", temp2);
|
fprintf(Tf, "File %s\r\n", temp2);
|
||||||
free(temp2);
|
free(temp2);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: .TIC files magic processing.
|
* Purpose ...............: .TIC files magic processing.
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -49,27 +49,27 @@ char *Magic_Macro(int C)
|
|||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
switch(toupper(C)) {
|
switch(toupper(C)) {
|
||||||
case 'F': sprintf(buf, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
case 'F': snprintf(buf, PATH_MAX, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
||||||
break;
|
break;
|
||||||
case 'P': sprintf(buf, "%s", TIC.BBSpath);
|
case 'P': snprintf(buf, PATH_MAX, "%s", TIC.BBSpath);
|
||||||
break;
|
break;
|
||||||
case 'N': sprintf(buf, "%s", strtok(strdup(TIC.NewFile), "."));
|
case 'N': snprintf(buf, PATH_MAX, "%s", strtok(strdup(TIC.NewFile), "."));
|
||||||
break;
|
break;
|
||||||
case 'E': sprintf(buf, "%s", strrchr(TIC.NewFile, '.'));
|
case 'E': snprintf(buf, PATH_MAX, "%s", strrchr(TIC.NewFile, '.'));
|
||||||
break;
|
break;
|
||||||
case 'L': sprintf(buf, "%s", strrchr(TIC.NewFile, '.'));
|
case 'L': snprintf(buf, PATH_MAX, "%s", strrchr(TIC.NewFile, '.'));
|
||||||
buf[0] = buf[1];
|
buf[0] = buf[1];
|
||||||
buf[1] = buf[2];
|
buf[1] = buf[2];
|
||||||
buf[2] = '\0';
|
buf[2] = '\0';
|
||||||
break;
|
break;
|
||||||
case 'D': sprintf(buf, "%03d", Day_Of_Year());
|
case 'D': snprintf(buf, 3, "%03d", Day_Of_Year());
|
||||||
break;
|
break;
|
||||||
case 'C': sprintf(buf, "%03d", Day_Of_Year());
|
case 'C': snprintf(buf, 3, "%03d", Day_Of_Year());
|
||||||
buf[0] = buf[1];
|
buf[0] = buf[1];
|
||||||
buf[1] = buf[2];
|
buf[1] = buf[2];
|
||||||
buf[2] = '\0';
|
buf[2] = '\0';
|
||||||
break;
|
break;
|
||||||
case 'A': sprintf(buf, "%s", TIC.TicIn.Area);
|
case 'A': snprintf(buf, PATH_MAX, "%s", TIC.TicIn.Area);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ int GetMagicRec(int Typ, int First)
|
|||||||
MagicNr = 0;
|
MagicNr = 0;
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s/etc/magic.data", getenv("MBSE_ROOT"));
|
snprintf(temp, PATH_MAX, "%s/etc/magic.data", getenv("MBSE_ROOT"));
|
||||||
if ((FeM = fopen(temp, "r")) == NULL) {
|
if ((FeM = fopen(temp, "r")) == NULL) {
|
||||||
Syslog('+', "Huh? No magic file? (%s)", temp);
|
Syslog('+', "Huh? No magic file? (%s)", temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
@ -147,7 +147,7 @@ void MagicResult(char *format, ...)
|
|||||||
outputstr = calloc(1024, sizeof(char));
|
outputstr = calloc(1024, sizeof(char));
|
||||||
|
|
||||||
va_start(va_ptr, format);
|
va_start(va_ptr, format);
|
||||||
vsprintf(outputstr, format, va_ptr);
|
vsnprintf(outputstr, 1024, format, va_ptr);
|
||||||
va_end(va_ptr);
|
va_end(va_ptr);
|
||||||
|
|
||||||
Syslog('+', "Magic: %s", outputstr);
|
Syslog('+', "Magic: %s", outputstr);
|
||||||
@ -200,7 +200,7 @@ void Magic_ExecCommand(void)
|
|||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
Temp[0] = '\0';
|
Temp[0] = '\0';
|
||||||
sprintf(Temp, "%s", Magic_Macro(magic.Cmd[i]));
|
snprintf(Temp, PATH_MAX, "%s", Magic_Macro(magic.Cmd[i]));
|
||||||
for (k = 0; k < strlen(Temp); k++) {
|
for (k = 0; k < strlen(Temp); k++) {
|
||||||
Line[j] = Temp[k];
|
Line[j] = Temp[k];
|
||||||
j++;
|
j++;
|
||||||
@ -236,8 +236,8 @@ void Magic_CopyFile(void)
|
|||||||
|
|
||||||
while (GetMagicRec(MG_COPY, First)) {
|
while (GetMagicRec(MG_COPY, First)) {
|
||||||
First = FALSE;
|
First = FALSE;
|
||||||
sprintf(From, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
snprintf(From, PATH_MAX, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
||||||
sprintf(To, "%s/%s", magic.Path, TIC.NewFile);
|
snprintf(To, PATH_MAX, "%s/%s", magic.Path, TIC.NewFile);
|
||||||
|
|
||||||
if ((rc = file_cp(From, To) == 0)) {
|
if ((rc = file_cp(From, To) == 0)) {
|
||||||
MagicResult((char *)"%s copied to %s", From, To);
|
MagicResult((char *)"%s copied to %s", From, To);
|
||||||
@ -264,7 +264,7 @@ void Magic_UnpackFile(void)
|
|||||||
getcwd(buf, 128);
|
getcwd(buf, 128);
|
||||||
|
|
||||||
if (chdir(magic.Path) == 0) {
|
if (chdir(magic.Path) == 0) {
|
||||||
sprintf(Fn, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
snprintf(Fn, PATH_MAX, "%s/%s", TIC.BBSpath, TIC.NewFile);
|
||||||
if ((unarc = unpacker(Fn)) != NULL) {
|
if ((unarc = unpacker(Fn)) != NULL) {
|
||||||
if (getarchiver(unarc)) {
|
if (getarchiver(unarc)) {
|
||||||
cmd = xstrcpy(archiver.munarc);
|
cmd = xstrcpy(archiver.munarc);
|
||||||
@ -325,7 +325,7 @@ void Magic_AdoptFile(void)
|
|||||||
if (SearchTic(magic.ToArea)) {
|
if (SearchTic(magic.ToArea)) {
|
||||||
MagicResult((char *)"Adoptfile in %s", magic.ToArea);
|
MagicResult((char *)"Adoptfile in %s", magic.ToArea);
|
||||||
|
|
||||||
sprintf(temp, "%s/%s", TIC.Inbound, MakeTicName());
|
snprintf(temp, PATH_MAX, "%s/%s", TIC.Inbound, MakeTicName());
|
||||||
if ((Tf = fopen(temp, "a+")) == NULL)
|
if ((Tf = fopen(temp, "a+")) == NULL)
|
||||||
WriteError("$Can't create %s", temp);
|
WriteError("$Can't create %s", temp);
|
||||||
else {
|
else {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: Make tag files
|
* Purpose ...............: Make tag files
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:2801/16
|
* Michiel Broek FIDO: 2:2801/16
|
||||||
* Beekmansbos 10 Internet: mbroek@ux123.pttnwb.nl
|
* Beekmansbos 10 Internet: mbroek@ux123.pttnwb.nl
|
||||||
@ -45,8 +45,8 @@ void MakeTags(void)
|
|||||||
tname = calloc(PATH_MAX, sizeof(char));
|
tname = calloc(PATH_MAX, sizeof(char));
|
||||||
aname = calloc(PATH_MAX, sizeof(char));
|
aname = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
sprintf(gname, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
|
snprintf(gname, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
|
||||||
sprintf(dname, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
snprintf(dname, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
||||||
|
|
||||||
if (((fg = fopen(gname, "r")) == NULL) || ((fd = fopen(dname, "r")) == NULL)) {
|
if (((fg = fopen(gname, "r")) == NULL) || ((fd = fopen(dname, "r")) == NULL)) {
|
||||||
WriteError("$Can't open data");
|
WriteError("$Can't open data");
|
||||||
@ -56,10 +56,10 @@ void MakeTags(void)
|
|||||||
|
|
||||||
while ((fread(&mgroup, mgrouphdr.recsize, 1, fg)) == 1) {
|
while ((fread(&mgroup, mgrouphdr.recsize, 1, fg)) == 1) {
|
||||||
if (mgroup.Active) {
|
if (mgroup.Active) {
|
||||||
sprintf(tname, "%s/share/doc/tags/%s.msgs.tag", getenv("MBSE_ROOT"), mgroup.Name);
|
snprintf(tname, PATH_MAX, "%s/share/doc/tags/%s.msgs.tag", getenv("MBSE_ROOT"), mgroup.Name);
|
||||||
mkdirs(tname, 0755);
|
mkdirs(tname, 0755);
|
||||||
td = fopen(tname, "w");
|
td = fopen(tname, "w");
|
||||||
sprintf(aname, "%s/share/doc/tags/%s.msgs.are", getenv("MBSE_ROOT"), mgroup.Name);
|
snprintf(aname, PATH_MAX, "%s/share/doc/tags/%s.msgs.are", getenv("MBSE_ROOT"), mgroup.Name);
|
||||||
ad = fopen(aname, "w");
|
ad = fopen(aname, "w");
|
||||||
fprintf(ad, "; Mail areas in group %s\n", mgroup.Name);
|
fprintf(ad, "; Mail areas in group %s\n", mgroup.Name);
|
||||||
fprintf(ad, ";\n");
|
fprintf(ad, ";\n");
|
||||||
@ -81,8 +81,8 @@ void MakeTags(void)
|
|||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(gname, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
snprintf(gname, PATH_MAX, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
||||||
sprintf(dname, "%s/etc/tic.data", getenv("MBSE_ROOT"));
|
snprintf(dname, PATH_MAX, "%s/etc/tic.data", getenv("MBSE_ROOT"));
|
||||||
|
|
||||||
if (((fg = fopen(gname, "r")) == NULL) || ((fd = fopen(dname, "r")) == NULL)) {
|
if (((fg = fopen(gname, "r")) == NULL) || ((fd = fopen(dname, "r")) == NULL)) {
|
||||||
WriteError("$Can't open data");
|
WriteError("$Can't open data");
|
||||||
@ -92,9 +92,9 @@ void MakeTags(void)
|
|||||||
|
|
||||||
while ((fread(&fgroup, fgrouphdr.recsize, 1, fg)) == 1) {
|
while ((fread(&fgroup, fgrouphdr.recsize, 1, fg)) == 1) {
|
||||||
if (fgroup.Active) {
|
if (fgroup.Active) {
|
||||||
sprintf(tname, "%s/share/doc/tags/%s.file.tag", getenv("MBSE_ROOT"), fgroup.Name);
|
snprintf(tname, PATH_MAX, "%s/share/doc/tags/%s.file.tag", getenv("MBSE_ROOT"), fgroup.Name);
|
||||||
td = fopen(tname, "w");
|
td = fopen(tname, "w");
|
||||||
sprintf(aname, "%s/share/doc/tags/%s.file.are", getenv("MBSE_ROOT"), fgroup.Name);
|
snprintf(aname, PATH_MAX, "%s/share/doc/tags/%s.file.are", getenv("MBSE_ROOT"), fgroup.Name);
|
||||||
ad = fopen(aname, "w");
|
ad = fopen(aname, "w");
|
||||||
fprintf(ad, "; TIC file areas in group %s\n", fgroup.Name);
|
fprintf(ad, "; TIC file areas in group %s\n", fgroup.Name);
|
||||||
fprintf(ad, ";\n");
|
fprintf(ad, ";\n");
|
||||||
|
@ -77,11 +77,11 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(temp, "%s/%s", pwd, File);
|
snprintf(temp, PATH_MAX, "%s/%s", pwd, File);
|
||||||
sprintf(tmpdir, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
snprintf(tmpdir, PATH_MAX, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||||
if ((unarc = unpacker(File)) == NULL) {
|
if ((unarc = unpacker(File)) == NULL) {
|
||||||
Syslog('+', "No known archive: %s", File);
|
Syslog('+', "No known archive: %s", File);
|
||||||
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File);
|
snprintf(temp2, PATH_MAX, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), File);
|
||||||
mkdirs(temp2, 0755);
|
mkdirs(temp2, 0755);
|
||||||
if ((rc = file_cp(temp, temp2))) {
|
if ((rc = file_cp(temp, temp2))) {
|
||||||
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
|
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
|
||||||
@ -150,12 +150,12 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
/*
|
/*
|
||||||
* Try to get a FILE_ID.DIZ
|
* Try to get a FILE_ID.DIZ
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
snprintf(temp, PATH_MAX, "%s/tmp/arc/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
sprintf(temp2, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
snprintf(temp2, PATH_MAX, "%s/tmp/FILE_ID.DIZ", getenv("MBSE_ROOT"));
|
||||||
if (file_cp(temp, temp2) == 0) {
|
if (file_cp(temp, temp2) == 0) {
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
snprintf(temp, PATH_MAX, "%s/tmp/arc/file_id.diz", getenv("MBSE_ROOT"));
|
||||||
if (file_cp(temp, temp2) == 0)
|
if (file_cp(temp, temp2) == 0)
|
||||||
File_Id = TRUE;
|
File_Id = TRUE;
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
f_db.Size = file_size(f_db.Name);
|
f_db.Size = file_size(f_db.Name);
|
||||||
f_db.Crc32 = file_crc(f_db.Name, TRUE);
|
f_db.Crc32 = file_crc(f_db.Name, TRUE);
|
||||||
f_db.FileDate = file_time(f_db.Name);
|
f_db.FileDate = file_time(f_db.Name);
|
||||||
sprintf(temp2, "%s/%s", area.Path, f_db.Name);
|
snprintf(temp2, PATH_MAX, "%s/%s", area.Path, f_db.Name);
|
||||||
|
|
||||||
if (!do_quiet) {
|
if (!do_quiet) {
|
||||||
printf("Adding \b\b\b\b\b\b\b\b\b\b");
|
printf("Adding \b\b\b\b\b\b\b\b\b\b");
|
||||||
@ -293,7 +293,7 @@ void AdoptFile(int Area, char *File, char *Description)
|
|||||||
|
|
||||||
if (strcmp(f_db.Name, f_db.LName)) {
|
if (strcmp(f_db.Name, f_db.LName)) {
|
||||||
lname = calloc(PATH_MAX, sizeof(char));
|
lname = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(lname, "%s/%s", area.Path, f_db.LName);
|
snprintf(lname, PATH_MAX, "%s/%s", area.Path, f_db.LName);
|
||||||
if (AddFile(f_db, Area, temp2, f_db.Name, lname) == FALSE) {
|
if (AddFile(f_db, Area, temp2, f_db.Name, lname) == FALSE) {
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ void Check(long AreaNr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
iAreasNew = iTotal = iErrors = 0;
|
iAreasNew = iTotal = iErrors = 0;
|
||||||
sprintf(sAreas, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
snprintf(sAreas, PATH_MAX, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
||||||
|
|
||||||
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
||||||
WriteError("Can't open %s", sAreas);
|
WriteError("Can't open %s", sAreas);
|
||||||
@ -120,7 +120,7 @@ void Check(long AreaNr)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (strlen(area.Name) == 0) {
|
if (strlen(area.Name) == 0) {
|
||||||
sprintf(fAreas, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
|
snprintf(fAreas, PATH_MAX, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
|
||||||
if (unlink(fAreas) == 0) {
|
if (unlink(fAreas) == 0) {
|
||||||
Syslog('+', "Removed obsolete %s", fAreas);
|
Syslog('+', "Removed obsolete %s", fAreas);
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ void Check(long AreaNr)
|
|||||||
} else {
|
} else {
|
||||||
while ((de = readdir(dp))) {
|
while ((de = readdir(dp))) {
|
||||||
if (de->d_name[0] != '.') {
|
if (de->d_name[0] != '.') {
|
||||||
sprintf(temp, "%s/%s", CFG.req_magic, de->d_name);
|
snprintf(temp, PATH_MAX, "%s/%s", CFG.req_magic, de->d_name);
|
||||||
if (file_exist(temp, X_OK) == 0) {
|
if (file_exist(temp, X_OK) == 0) {
|
||||||
Syslog('f', "%s is executable", temp);
|
Syslog('f', "%s is executable", temp);
|
||||||
} else if (file_exist(temp, R_OK) == 0) {
|
} else if (file_exist(temp, R_OK) == 0) {
|
||||||
@ -155,7 +155,7 @@ void Check(long AreaNr)
|
|||||||
fgets(mname, PATH_MAX -1, pFile);
|
fgets(mname, PATH_MAX -1, pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
Striplf(mname);
|
Striplf(mname);
|
||||||
sprintf(newdir, "%s/etc/request.index", getenv("MBSE_ROOT"));
|
snprintf(newdir, PATH_MAX, "%s/etc/request.index", getenv("MBSE_ROOT"));
|
||||||
Found = FALSE;
|
Found = FALSE;
|
||||||
if ((pFile = fopen(newdir, "r"))) {
|
if ((pFile = fopen(newdir, "r"))) {
|
||||||
while (fread(&idx, sizeof(idx), 1, pFile)) {
|
while (fread(&idx, sizeof(idx), 1, pFile)) {
|
||||||
@ -228,7 +228,7 @@ void CheckArea(long Area)
|
|||||||
*/
|
*/
|
||||||
if (access(area.Path, R_OK) == -1) {
|
if (access(area.Path, R_OK) == -1) {
|
||||||
Syslog('!', "No dir: %s", area.Path);
|
Syslog('!', "No dir: %s", area.Path);
|
||||||
sprintf(newdir, "%s/foobar", area.Path);
|
snprintf(newdir, PATH_MAX, "%s/foobar", area.Path);
|
||||||
mkdirs(newdir, 0775);
|
mkdirs(newdir, 0775);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,8 +300,8 @@ void CheckArea(long Area)
|
|||||||
|
|
||||||
iTotal++;
|
iTotal++;
|
||||||
inArea++;
|
inArea++;
|
||||||
sprintf(newdir, "%s/%s", area.Path, fdb.LName);
|
snprintf(newdir, PATH_MAX, "%s/%s", area.Path, fdb.LName);
|
||||||
sprintf(mname, "%s/%s", area.Path, fdb.Name);
|
snprintf(mname, PATH_MAX, "%s/%s", area.Path, fdb.Name);
|
||||||
|
|
||||||
if (file_exist(newdir, R_OK) && file_exist(mname, R_OK)) {
|
if (file_exist(newdir, R_OK) && file_exist(mname, R_OK)) {
|
||||||
Syslog('+', "File %s area %ld not on disk.", newdir, Area);
|
Syslog('+', "File %s area %ld not on disk.", newdir, Area);
|
||||||
@ -324,13 +324,13 @@ void CheckArea(long Area)
|
|||||||
|
|
||||||
strcpy(temp, fdb.LName);
|
strcpy(temp, fdb.LName);
|
||||||
name_mangle(temp);
|
name_mangle(temp);
|
||||||
sprintf(mname, "%s/%s", area.Path, temp);
|
snprintf(mname, PATH_MAX, "%s/%s", area.Path, temp);
|
||||||
if (strcmp(fdb.Name, temp)) {
|
if (strcmp(fdb.Name, temp)) {
|
||||||
Syslog('!', "Converted %s to %s", fdb.Name, temp);
|
Syslog('!', "Converted %s to %s", fdb.Name, temp);
|
||||||
tname = calloc(PATH_MAX, sizeof(char));
|
tname = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(tname, "%s/%s", area.Path, fdb.Name);
|
snprintf(tname, PATH_MAX, "%s/%s", area.Path, fdb.Name);
|
||||||
rename(tname, mname);
|
rename(tname, mname);
|
||||||
sprintf(tname, "%s/%s", area.Path, fdb.LName);
|
snprintf(tname, PATH_MAX, "%s/%s", area.Path, fdb.LName);
|
||||||
unlink(tname);
|
unlink(tname);
|
||||||
symlink(mname, tname);
|
symlink(mname, tname);
|
||||||
free(tname);
|
free(tname);
|
||||||
@ -347,10 +347,10 @@ void CheckArea(long Area)
|
|||||||
* 8.3 and LFN are the same.
|
* 8.3 and LFN are the same.
|
||||||
*/
|
*/
|
||||||
tname = calloc(PATH_MAX, sizeof(char));
|
tname = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(tname, "%s/%s", area.Path, fdb.LName);
|
snprintf(tname, PATH_MAX, "%s/%s", area.Path, fdb.LName);
|
||||||
for (j = 0; j < strlen(fdb.LName); j++)
|
for (j = 0; j < strlen(fdb.LName); j++)
|
||||||
fdb.LName[j] = tolower(fdb.LName[j]);
|
fdb.LName[j] = tolower(fdb.LName[j]);
|
||||||
sprintf(newdir, "%s/%s", area.Path, fdb.LName);
|
snprintf(newdir, PATH_MAX, "%s/%s", area.Path, fdb.LName);
|
||||||
if (strcmp(tname, newdir)) {
|
if (strcmp(tname, newdir)) {
|
||||||
Syslog('+', "Rename LFN from %s to %s", fdb.Name, fdb.LName);
|
Syslog('+', "Rename LFN from %s to %s", fdb.Name, fdb.LName);
|
||||||
rename(tname, newdir);
|
rename(tname, newdir);
|
||||||
@ -433,7 +433,7 @@ void CheckArea(long Area)
|
|||||||
* It could be that there is a thumbnail made of the 8.3 filename
|
* It could be that there is a thumbnail made of the 8.3 filename
|
||||||
*/
|
*/
|
||||||
tname = calloc(PATH_MAX, sizeof(char));
|
tname = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(tname, "%s/.%s", area.Path, fdb.Name);
|
snprintf(tname, PATH_MAX, "%s/.%s", area.Path, fdb.Name);
|
||||||
if (file_exist(tname, R_OK) == 0) {
|
if (file_exist(tname, R_OK) == 0) {
|
||||||
Syslog('+', "Removing wrong 8.3 thumbnail %s", tname);
|
Syslog('+', "Removing wrong 8.3 thumbnail %s", tname);
|
||||||
iErrors++;
|
iErrors++;
|
||||||
@ -532,7 +532,7 @@ void CheckArea(long Area)
|
|||||||
(strncmp(de->d_name, "header", 6)) &&
|
(strncmp(de->d_name, "header", 6)) &&
|
||||||
(strncmp(de->d_name, "index", 5)) &&
|
(strncmp(de->d_name, "index", 5)) &&
|
||||||
(strncmp(de->d_name, "readme", 6))) {
|
(strncmp(de->d_name, "readme", 6))) {
|
||||||
sprintf(fn, "%s/%s", area.Path, de->d_name);
|
snprintf(fn, PATH_MAX, "%s/%s", area.Path, de->d_name);
|
||||||
if (stat(fn, &stb) == 0)
|
if (stat(fn, &stb) == 0)
|
||||||
if (S_ISREG(stb.st_mode)) {
|
if (S_ISREG(stb.st_mode)) {
|
||||||
if (unlink(fn) == 0) {
|
if (unlink(fn) == 0) {
|
||||||
|
@ -177,7 +177,7 @@ void editor_configs(void)
|
|||||||
/*
|
/*
|
||||||
* Export ~/etc/msg.txt for MsgEd.
|
* Export ~/etc/msg.txt for MsgEd.
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "%s/etc/msg.txt", getenv("MBSE_ROOT"));
|
snprintf(temp, PATH_MAX, "%s/etc/msg.txt", getenv("MBSE_ROOT"));
|
||||||
if ((fp = fopen(temp, "w")) != NULL) {
|
if ((fp = fopen(temp, "w")) != NULL) {
|
||||||
fprintf(fp, "; msg.txt -- Automatic created by mbsetup %s -- Do not edit!\n;\n", VERSION);
|
fprintf(fp, "; msg.txt -- Automatic created by mbsetup %s -- Do not edit!\n;\n", VERSION);
|
||||||
fprintf(fp, "; Mail areas for MsgEd.\n;\n");
|
fprintf(fp, "; Mail areas for MsgEd.\n;\n");
|
||||||
@ -191,7 +191,7 @@ void editor_configs(void)
|
|||||||
/*
|
/*
|
||||||
* Export ~/etc/golded.inc for GoldED
|
* Export ~/etc/golded.inc for GoldED
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "%s/etc/golded.inc", getenv("MBSE_ROOT"));
|
snprintf(temp, PATH_MAX, "%s/etc/golded.inc", getenv("MBSE_ROOT"));
|
||||||
if ((fp = fopen(temp, "w")) != NULL) {
|
if ((fp = fopen(temp, "w")) != NULL) {
|
||||||
fprintf(fp, "; GoldED.inc -- Automatic created by mbsetup %s -- Do not edit!\n\n", VERSION);
|
fprintf(fp, "; GoldED.inc -- Automatic created by mbsetup %s -- Do not edit!\n\n", VERSION);
|
||||||
fprintf(fp, "; Basic information.\n;\n");
|
fprintf(fp, "; Basic information.\n;\n");
|
||||||
@ -419,7 +419,7 @@ int main(int argc, char **argv)
|
|||||||
((strchr(argv[i + 1], ':') != NULL) ||
|
((strchr(argv[i + 1], ':') != NULL) ||
|
||||||
(atoi(argv[i + 1])) ||
|
(atoi(argv[i + 1])) ||
|
||||||
(strncmp(argv[i + 1], "*", 1) == 0))) {
|
(strncmp(argv[i + 1], "*", 1) == 0))) {
|
||||||
sprintf(Options, "%s", argv[i + 1]);
|
snprintf(Options, 81, "%s", argv[i + 1]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,7 +559,7 @@ int main(int argc, char **argv)
|
|||||||
* Read alias file
|
* Read alias file
|
||||||
*/
|
*/
|
||||||
cmd = calloc(PATH_MAX, sizeof(char));
|
cmd = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(cmd, "%s/etc/aliases", getenv("MBSE_ROOT"));
|
snprintf(cmd, PATH_MAX, "%s/etc/aliases", getenv("MBSE_ROOT"));
|
||||||
if ((do_news || do_scan || do_toss || do_mail) && file_exist(cmd, R_OK) == 0)
|
if ((do_news || do_scan || do_toss || do_mail) && file_exist(cmd, R_OK) == 0)
|
||||||
readalias(cmd);
|
readalias(cmd);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose: File Database Maintenance - Import files with files.bbs
|
* Purpose: File Database Maintenance - Import files with files.bbs
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2004
|
* Copyright (C) 1997-2005
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -58,7 +58,7 @@ void ImportFiles(int Area)
|
|||||||
mbse_colour(CYAN, BLACK);
|
mbse_colour(CYAN, BLACK);
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "xxxxx%d", getpid());
|
snprintf(temp, PATH_MAX, "xxxxx%d", getpid());
|
||||||
if ((fbbs = fopen(temp, "a+")) == NULL) {
|
if ((fbbs = fopen(temp, "a+")) == NULL) {
|
||||||
WriteError("$Can't write to directory");
|
WriteError("$Can't write to directory");
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
@ -86,14 +86,14 @@ void ImportFiles(int Area)
|
|||||||
getcwd(pwd, PATH_MAX);
|
getcwd(pwd, PATH_MAX);
|
||||||
if (CheckFDB(Area, area.Path))
|
if (CheckFDB(Area, area.Path))
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
sprintf(tmpdir, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
snprintf(tmpdir, PATH_MAX, "%s/tmp/arc", getenv("MBSE_ROOT"));
|
||||||
|
|
||||||
IsDoing("Import files");
|
IsDoing("Import files");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find and open files.bbs
|
* Find and open files.bbs
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "FILES.BBS");
|
snprintf(temp, PATH_MAX, "FILES.BBS");
|
||||||
if (getfilecase(area.Path, temp) == FALSE) {
|
if (getfilecase(area.Path, temp) == FALSE) {
|
||||||
WriteError("Can't find files.bbs anywhere");
|
WriteError("Can't find files.bbs anywhere");
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
@ -117,7 +117,7 @@ void ImportFiles(int Area)
|
|||||||
Doit = TRUE;
|
Doit = TRUE;
|
||||||
if ((unarc = unpacker(temp)) == NULL) {
|
if ((unarc = unpacker(temp)) == NULL) {
|
||||||
Syslog('+', "Unknown archive format %s", temp);
|
Syslog('+', "Unknown archive format %s", temp);
|
||||||
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), f_db.Name);
|
snprintf(temp2, PATH_MAX, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), f_db.Name);
|
||||||
mkdirs(temp2, 0755);
|
mkdirs(temp2, 0755);
|
||||||
if ((rc = file_cp(temp, temp2))) {
|
if ((rc = file_cp(temp, temp2))) {
|
||||||
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
|
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
|
||||||
@ -238,7 +238,7 @@ void ImportFiles(int Area)
|
|||||||
strcpy(f_db.Name, temp2);
|
strcpy(f_db.Name, temp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(temp, "%s/%s", pwd, fod);
|
snprintf(temp, PATH_MAX, "%s/%s", pwd, fod);
|
||||||
stat(temp, &statfile);
|
stat(temp, &statfile);
|
||||||
|
|
||||||
if (do_annon)
|
if (do_annon)
|
||||||
@ -310,8 +310,8 @@ void ImportFiles(int Area)
|
|||||||
strcpy(f_db.Desc[0], "No description");
|
strcpy(f_db.Desc[0], "No description");
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(dest, "%s/%s", area.Path, f_db.Name);
|
snprintf(dest, PATH_MAX, "%s/%s", area.Path, f_db.Name);
|
||||||
sprintf(lname, "%s/%s", area.Path, f_db.LName);
|
snprintf(lname, PATH_MAX, "%s/%s", area.Path, f_db.LName);
|
||||||
Append = TRUE;
|
Append = TRUE;
|
||||||
f_db.Size = statfile.st_size;
|
f_db.Size = statfile.st_size;
|
||||||
f_db.FileDate = statfile.st_mtime;
|
f_db.FileDate = statfile.st_mtime;
|
||||||
@ -375,7 +375,7 @@ void ImportFiles(int Area)
|
|||||||
Doit = TRUE;
|
Doit = TRUE;
|
||||||
if ((unarc = unpacker(temp)) == NULL) {
|
if ((unarc = unpacker(temp)) == NULL) {
|
||||||
Syslog('+', "Unknown archive format %s", temp);
|
Syslog('+', "Unknown archive format %s", temp);
|
||||||
sprintf(temp2, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), f_db.LName);
|
snprintf(temp2, PATH_MAX, "%s/tmp/arc/%s", getenv("MBSE_ROOT"), f_db.LName);
|
||||||
mkdirs(temp2, 0755);
|
mkdirs(temp2, 0755);
|
||||||
if ((rc = file_cp(temp, temp2))) {
|
if ((rc = file_cp(temp, temp2))) {
|
||||||
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
|
WriteError("Can't copy file to %s, %s", temp2, strerror(rc));
|
||||||
|
@ -215,7 +215,7 @@ char *rfcdate(time_t now)
|
|||||||
|
|
||||||
ptm = *gmtime(&now);
|
ptm = *gmtime(&now);
|
||||||
|
|
||||||
sprintf(buf,"%s, %02d %s %04d %02d:%02d:%02d GMT",
|
snprintf(buf,40,"%s, %02d %s %04d %02d:%02d:%02d GMT",
|
||||||
wdays[ptm.tm_wday], ptm.tm_mday, months[ptm.tm_mon],
|
wdays[ptm.tm_wday], ptm.tm_mday, months[ptm.tm_mon],
|
||||||
ptm.tm_year + 1900, ptm.tm_hour, ptm.tm_min, ptm.tm_sec);
|
ptm.tm_year + 1900, ptm.tm_hour, ptm.tm_min, ptm.tm_sec);
|
||||||
return(buf);
|
return(buf);
|
||||||
@ -233,18 +233,18 @@ void pagelink(FILE *fa, char *Path, int inArea, int Current)
|
|||||||
|
|
||||||
if ((Current >= CFG.www_files_page) && (inArea >= CFG.www_files_page)) {
|
if ((Current >= CFG.www_files_page) && (inArea >= CFG.www_files_page)) {
|
||||||
if (((Current / CFG.www_files_page) - 1) > 0) {
|
if (((Current / CFG.www_files_page) - 1) > 0) {
|
||||||
sprintf(nr, "%d", (Current / CFG.www_files_page) -1);
|
snprintf(nr, 25, "%d", (Current / CFG.www_files_page) -1);
|
||||||
} else {
|
} else {
|
||||||
nr[0] = '\0';
|
nr[0] = '\0';
|
||||||
}
|
}
|
||||||
sprintf(temp, "%s/%s%s/index%s.html", CFG.www_url, CFG.www_link2ftp, Path+strlen(CFG.ftp_base), nr);
|
snprintf(temp, 256, "%s/%s%s/index%s.html", CFG.www_url, CFG.www_link2ftp, Path+strlen(CFG.ftp_base), nr);
|
||||||
MacroVars("c", "s", temp);
|
MacroVars("c", "s", temp);
|
||||||
} else {
|
} else {
|
||||||
MacroVars("c", "s", "");
|
MacroVars("c", "s", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Current < (inArea - CFG.www_files_page)) && (inArea >= CFG.www_files_page)) {
|
if ((Current < (inArea - CFG.www_files_page)) && (inArea >= CFG.www_files_page)) {
|
||||||
sprintf(temp, "%s/%s%s/index%d.html", CFG.www_url, CFG.www_link2ftp, Path+strlen(CFG.ftp_base),
|
snprintf(temp, 256, "%s/%s%s/index%d.html", CFG.www_url, CFG.www_link2ftp, Path+strlen(CFG.ftp_base),
|
||||||
(Current / CFG.www_files_page) + 1);
|
(Current / CFG.www_files_page) + 1);
|
||||||
MacroVars("d", "s", temp);
|
MacroVars("d", "s", temp);
|
||||||
} else {
|
} else {
|
||||||
@ -265,14 +265,14 @@ FILE *newpage(char *Path, char *Name, time_t later, int inArea, int Current, FIL
|
|||||||
|
|
||||||
lastfile = Current;
|
lastfile = Current;
|
||||||
if (Current)
|
if (Current)
|
||||||
sprintf(linebuf, "%s/index%d.temp", Path, Current / CFG.www_files_page);
|
snprintf(linebuf, 1024, "%s/index%d.temp", Path, Current / CFG.www_files_page);
|
||||||
else
|
else
|
||||||
sprintf(linebuf, "%s/index.temp", Path);
|
snprintf(linebuf, 1024, "%s/index.temp", Path);
|
||||||
if ((fa = fopen(linebuf, "w")) == NULL) {
|
if ((fa = fopen(linebuf, "w")) == NULL) {
|
||||||
WriteError("$Can't create %s", linebuf);
|
WriteError("$Can't create %s", linebuf);
|
||||||
} else {
|
} else {
|
||||||
sprintf(linebuf, "%s", Name);
|
snprintf(linebuf, 1024, "%s", Name);
|
||||||
html_massage(linebuf, outbuf, 1023);
|
html_massage(linebuf, outbuf, 1024);
|
||||||
MacroVars("ab", "ss", rfcdate(later), outbuf);
|
MacroVars("ab", "ss", rfcdate(later), outbuf);
|
||||||
pagelink(fa, Path, inArea, Current);
|
pagelink(fa, Path, inArea, Current);
|
||||||
MacroRead(fi, fa);
|
MacroRead(fi, fa);
|
||||||
@ -299,11 +299,11 @@ void closepage(FILE *fa, char *Path, int inArea, int Current, FILE *fi)
|
|||||||
MacroRead(fi, fa);
|
MacroRead(fi, fa);
|
||||||
fclose(fa);
|
fclose(fa);
|
||||||
if (lastfile) {
|
if (lastfile) {
|
||||||
sprintf(temp1, "%s/index%d.html", Path, lastfile / CFG.www_files_page);
|
snprintf(temp1, PATH_MAX, "%s/index%d.html", Path, lastfile / CFG.www_files_page);
|
||||||
sprintf(temp2, "%s/index%d.temp", Path, lastfile / CFG.www_files_page);
|
snprintf(temp2, PATH_MAX, "%s/index%d.temp", Path, lastfile / CFG.www_files_page);
|
||||||
} else {
|
} else {
|
||||||
sprintf(temp1, "%s/index.html", Path);
|
snprintf(temp1, PATH_MAX, "%s/index.html", Path);
|
||||||
sprintf(temp2, "%s/index.temp", Path);
|
snprintf(temp2, PATH_MAX, "%s/index.temp", Path);
|
||||||
}
|
}
|
||||||
rename(temp2, temp1);
|
rename(temp2, temp1);
|
||||||
chmod(temp1, 0644);
|
chmod(temp1, 0644);
|
||||||
@ -341,13 +341,13 @@ void ReqIndex(void)
|
|||||||
sIndex = calloc(PATH_MAX, sizeof(char));
|
sIndex = calloc(PATH_MAX, sizeof(char));
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
|
||||||
sprintf(sAreas, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
snprintf(sAreas, PATH_MAX, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
||||||
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
||||||
WriteError("$Can't open %s", sAreas);
|
WriteError("$Can't open %s", sAreas);
|
||||||
die(MBERR_INIT_ERROR);
|
die(MBERR_INIT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(sIndex, "%s/etc/request.index", getenv("MBSE_ROOT"));
|
snprintf(sIndex, PATH_MAX, "%s/etc/request.index", getenv("MBSE_ROOT"));
|
||||||
if ((pIndex = fopen(sIndex, "w")) == NULL) {
|
if ((pIndex = fopen(sIndex, "w")) == NULL) {
|
||||||
WriteError("$Can't create %s", sIndex);
|
WriteError("$Can't create %s", sIndex);
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
@ -386,7 +386,7 @@ void ReqIndex(void)
|
|||||||
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
sprintf(temp, "%s/var/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
|
snprintf(temp, PATH_MAX, "%s/var/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
|
||||||
db_time = (int) file_time(temp);
|
db_time = (int) file_time(temp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -402,8 +402,8 @@ void ReqIndex(void)
|
|||||||
if ((iTotal % 10) == 0)
|
if ((iTotal % 10) == 0)
|
||||||
Marker();
|
Marker();
|
||||||
memset(&idx, 0, sizeof(idx));
|
memset(&idx, 0, sizeof(idx));
|
||||||
sprintf(idx.Name, "%s", tu(fdb.Name));
|
snprintf(idx.Name, 13, "%s", tu(fdb.Name));
|
||||||
sprintf(idx.LName, "%s", tu(fdb.LName));
|
snprintf(idx.LName, 81, "%s", tu(fdb.LName));
|
||||||
idx.AreaNum = i;
|
idx.AreaNum = i;
|
||||||
idx.Record = record;
|
idx.Record = record;
|
||||||
fill_index(idx, &fdx);
|
fill_index(idx, &fdx);
|
||||||
@ -415,7 +415,7 @@ void ReqIndex(void)
|
|||||||
/*
|
/*
|
||||||
* Create files.bbs if needed.
|
* Create files.bbs if needed.
|
||||||
*/
|
*/
|
||||||
sprintf(temp, "%s/files.bbs", area.Path);
|
snprintf(temp, PATH_MAX, "%s/files.bbs", area.Path);
|
||||||
obj_time = (int) file_time(temp);
|
obj_time = (int) file_time(temp);
|
||||||
|
|
||||||
if (obj_time < db_time) {
|
if (obj_time < db_time) {
|
||||||
@ -458,7 +458,7 @@ void ReqIndex(void)
|
|||||||
*/
|
*/
|
||||||
if (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0) {
|
if (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0) {
|
||||||
|
|
||||||
sprintf(temp, "%s/00index", area.Path);
|
snprintf(temp, PATH_MAX, "%s/00index", area.Path);
|
||||||
obj_time = (int) file_time(temp);
|
obj_time = (int) file_time(temp);
|
||||||
|
|
||||||
if (obj_time < db_time) {
|
if (obj_time < db_time) {
|
||||||
@ -552,7 +552,7 @@ void HtmlIndex(char *Lang)
|
|||||||
printf("\rCreate html pages... \n");
|
printf("\rCreate html pages... \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(sAreas, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
snprintf(sAreas, PATH_MAX, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
||||||
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
||||||
WriteError("$Can't open %s", sAreas);
|
WriteError("$Can't open %s", sAreas);
|
||||||
die(MBERR_INIT_ERROR);
|
die(MBERR_INIT_ERROR);
|
||||||
@ -567,7 +567,7 @@ void HtmlIndex(char *Lang)
|
|||||||
* download directories.
|
* download directories.
|
||||||
*/
|
*/
|
||||||
if (strlen(CFG.ftp_base) && strlen(CFG.www_url) && strlen(CFG.www_author) && strlen(CFG.www_charset)) {
|
if (strlen(CFG.ftp_base) && strlen(CFG.www_url) && strlen(CFG.www_author) && strlen(CFG.www_charset)) {
|
||||||
sprintf(fn, "%s/index.temp", CFG.ftp_base);
|
snprintf(fn, PATH_MAX, "%s/index.temp", CFG.ftp_base);
|
||||||
if ((fm = fopen(fn, "w")) == NULL) {
|
if ((fm = fopen(fn, "w")) == NULL) {
|
||||||
Syslog('+', "Can't open %s, skipping html pages creation", fn);
|
Syslog('+', "Can't open %s, skipping html pages creation", fn);
|
||||||
}
|
}
|
||||||
@ -622,9 +622,9 @@ void HtmlIndex(char *Lang)
|
|||||||
|
|
||||||
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
if ((fdb_area = mbsedb_OpenFDB(i, 30)) == NULL)
|
||||||
die(MBERR_GENERAL);
|
die(MBERR_GENERAL);
|
||||||
sprintf(temp, "%s/var/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
|
snprintf(temp, PATH_MAX, "%s/var/fdb/file%ld.data", getenv("MBSE_ROOT"), i);
|
||||||
db_time = (int) file_time(temp);
|
db_time = (int) file_time(temp);
|
||||||
sprintf(temp, "%s/index.html", area.Path);
|
snprintf(temp, PATH_MAX, "%s/index.html", area.Path);
|
||||||
obj_time = (int) file_time(temp);
|
obj_time = (int) file_time(temp);
|
||||||
|
|
||||||
if (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0)
|
if (strncmp(CFG.ftp_base, area.Path, strlen(CFG.ftp_base)) == 0)
|
||||||
@ -681,8 +681,8 @@ void HtmlIndex(char *Lang)
|
|||||||
isthumb = FALSE;
|
isthumb = FALSE;
|
||||||
if (strstr(fdb.LName, ".gif") || strstr(fdb.LName, ".jpg") ||
|
if (strstr(fdb.LName, ".gif") || strstr(fdb.LName, ".jpg") ||
|
||||||
strstr(fdb.LName, ".GIF") || strstr(fdb.LName, ".JPG")) {
|
strstr(fdb.LName, ".GIF") || strstr(fdb.LName, ".JPG")) {
|
||||||
sprintf(linebuf, "%s/%s", area.Path, fdb.LName);
|
snprintf(linebuf, 1024, "%s/%s", area.Path, fdb.LName);
|
||||||
sprintf(outbuf, "%s/.%s", area.Path, fdb.LName);
|
snprintf(outbuf, 1024, "%s/.%s", area.Path, fdb.LName);
|
||||||
if (file_exist(outbuf, R_OK)) {
|
if (file_exist(outbuf, R_OK)) {
|
||||||
if (strlen(CFG.www_convert)) {
|
if (strlen(CFG.www_convert)) {
|
||||||
if ((execute_str(CFG.www_convert, linebuf, outbuf,
|
if ((execute_str(CFG.www_convert, linebuf, outbuf,
|
||||||
@ -699,31 +699,31 @@ void HtmlIndex(char *Lang)
|
|||||||
isthumb = TRUE;
|
isthumb = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sprintf(outbuf, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
|
snprintf(outbuf, 1024, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
|
||||||
area.Path+strlen(CFG.ftp_base), fdb.LName);
|
area.Path+strlen(CFG.ftp_base), fdb.LName);
|
||||||
if (isthumb) {
|
if (isthumb) {
|
||||||
sprintf(linebuf, "%s/%s%s/.%s", CFG.www_url, CFG.www_link2ftp,
|
snprintf(linebuf, 1024, "%s/%s%s/.%s", CFG.www_url, CFG.www_link2ftp,
|
||||||
area.Path+strlen(CFG.ftp_base), fdb.LName);
|
area.Path+strlen(CFG.ftp_base), fdb.LName);
|
||||||
MacroVars("fghi", "dsss", 1, outbuf, fdb.LName, linebuf);
|
MacroVars("fghi", "dsss", 1, outbuf, fdb.LName, linebuf);
|
||||||
} else {
|
} else {
|
||||||
sprintf(outbuf, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
|
snprintf(outbuf, 1024, "%s/%s%s/%s", CFG.www_url, CFG.www_link2ftp,
|
||||||
area.Path+strlen(CFG.ftp_base), fdb.LName);
|
area.Path+strlen(CFG.ftp_base), fdb.LName);
|
||||||
MacroVars("fghi", "dsss", 0, outbuf, fdb.LName, "");
|
MacroVars("fghi", "dsss", 0, outbuf, fdb.LName, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(outbuf, "%lu Kb.", (long)(fdb.Size / 1024));
|
snprintf(outbuf, 1024, "%lu Kb.", (long)(fdb.Size / 1024));
|
||||||
MacroVars("jkl", "ssd", StrDateDMY(fdb.FileDate), outbuf, fdb.TimesDL);
|
MacroVars("jkl", "ssd", StrDateDMY(fdb.FileDate), outbuf, fdb.TimesDL);
|
||||||
memset(&desc, 0, sizeof(desc));
|
memset(&desc, 0, sizeof(desc));
|
||||||
k = 0;
|
k = 0;
|
||||||
for (j = 0; j < 25; j++)
|
for (j = 0; j < 25; j++)
|
||||||
if (strlen(fdb.Desc[j])) {
|
if (strlen(fdb.Desc[j])) {
|
||||||
if (j) {
|
if (j) {
|
||||||
sprintf(desc+k, "\n");
|
snprintf(desc+k, 2, "\n");
|
||||||
k += 1;
|
k += 1;
|
||||||
}
|
}
|
||||||
sprintf(linebuf, "%s", To_Html(fdb.Desc[j]));
|
snprintf(linebuf, 1024, "%s", To_Html(fdb.Desc[j]));
|
||||||
html_massage(linebuf, outbuf, 1023);
|
html_massage(linebuf, outbuf, 1024);
|
||||||
sprintf(desc+k, "%s", outbuf);
|
snprintf(desc+k, 6400 -k, "%s", outbuf);
|
||||||
k += strlen(outbuf);
|
k += strlen(outbuf);
|
||||||
}
|
}
|
||||||
MacroVars("m", "s", desc);
|
MacroVars("m", "s", desc);
|
||||||
@ -759,7 +759,7 @@ void HtmlIndex(char *Lang)
|
|||||||
filenr = lastfile / CFG.www_files_page;
|
filenr = lastfile / CFG.www_files_page;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
filenr++;
|
filenr++;
|
||||||
sprintf(linebuf, "%s/index%d.html", area.Path, filenr);
|
snprintf(linebuf, 1024, "%s/index%d.html", area.Path, filenr);
|
||||||
if (unlink(linebuf))
|
if (unlink(linebuf))
|
||||||
break;
|
break;
|
||||||
Syslog('+', "Removed obsolete %s", linebuf);
|
Syslog('+', "Removed obsolete %s", linebuf);
|
||||||
@ -781,12 +781,12 @@ void HtmlIndex(char *Lang)
|
|||||||
}
|
}
|
||||||
|
|
||||||
strcpy(linebuf, area.Name);
|
strcpy(linebuf, area.Name);
|
||||||
html_massage(linebuf, namebuf, 1023);
|
html_massage(linebuf, namebuf, 1024);
|
||||||
sprintf(linebuf, "%s/%s%s/index.html", CFG.www_url, CFG.www_link2ftp, area.Path+strlen(CFG.ftp_base));
|
snprintf(linebuf, 1024, "%s/%s%s/index.html", CFG.www_url, CFG.www_link2ftp, area.Path+strlen(CFG.ftp_base));
|
||||||
if (aSize > 1048576)
|
if (aSize > 1048576)
|
||||||
sprintf(outbuf, "%ld Mb.", aSize / 1048576);
|
snprintf(outbuf, 1024, "%ld Mb.", aSize / 1048576);
|
||||||
else
|
else
|
||||||
sprintf(outbuf, "%ld Kb.", aSize / 1024);
|
snprintf(outbuf, 1024, "%ld Kb.", aSize / 1024);
|
||||||
MacroVars("efghi", "dssds", AreaNr, linebuf, namebuf, aTotal, outbuf);
|
MacroVars("efghi", "dssds", AreaNr, linebuf, namebuf, aTotal, outbuf);
|
||||||
if (last == 0L)
|
if (last == 0L)
|
||||||
MacroVars("j", "s", " ");
|
MacroVars("j", "s", " ");
|
||||||
@ -800,13 +800,13 @@ void HtmlIndex(char *Lang)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fm) {
|
if (fm) {
|
||||||
sprintf(linebuf, "%ld Mb.", KSize / 1024);
|
snprintf(linebuf, 1024, "%ld Mb.", KSize / 1024);
|
||||||
MacroVars("cd", "ds", TotalHtml, linebuf);
|
MacroVars("cd", "ds", TotalHtml, linebuf);
|
||||||
MacroRead(fi, fm);
|
MacroRead(fi, fm);
|
||||||
fclose(fi);
|
fclose(fi);
|
||||||
MacroClear();
|
MacroClear();
|
||||||
fclose(fm);
|
fclose(fm);
|
||||||
sprintf(linebuf, "%s/index.html", CFG.ftp_base);
|
snprintf(linebuf, 1024, "%s/index.html", CFG.ftp_base);
|
||||||
rename(fn, linebuf);
|
rename(fn, linebuf);
|
||||||
chmod(linebuf, 0644);
|
chmod(linebuf, 0644);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user