Fixes for malformatted file description lines with tic processing
This commit is contained in:
parent
eb93569b53
commit
7e56a3b95a
@ -4743,6 +4743,9 @@ v0.33.20 10-Feb-2002
|
||||
removed if they are empty. Good for bulk areas create.
|
||||
When missing areas are created, uplink requests are sent to
|
||||
connect the areas.
|
||||
Added more checks to processing of file_id.diz files. Also
|
||||
when it is illegal formatted the already processed lines are
|
||||
cleared to prevent later malformatted descriptions.
|
||||
|
||||
mbmsg:
|
||||
When creating non-existend message bases, the path is created
|
||||
@ -4755,6 +4758,8 @@ v0.33.20 10-Feb-2002
|
||||
The check function now checks download directory permissions
|
||||
and tries to correct errors.
|
||||
Missing download directories are created mode 0775.
|
||||
Moved check for empty areas to mbfile check function.
|
||||
The mbfile move command now also moves the thumbnails.
|
||||
|
||||
mball:
|
||||
Will not crash anymore when it needs more then 10 minutes to
|
||||
|
4
TODO
4
TODO
@ -71,10 +71,6 @@ mbfile:
|
||||
|
||||
N: Rearc <area>
|
||||
|
||||
L: When files are moved from one area to another, the thumbnails
|
||||
are not moved. They are recreated later but this can be very
|
||||
time consuming.
|
||||
|
||||
mbaff:
|
||||
L: Add setup parameters for minimum length of keywords.
|
||||
|
||||
|
@ -63,7 +63,7 @@ extern int do_pack; /* Pack filebase */
|
||||
void Check(void)
|
||||
{
|
||||
FILE *pAreas, *pFile;
|
||||
int i, iAreas, iAreasNew = 0, Fix;
|
||||
int i, iAreas, iAreasNew = 0, Fix, inArea;
|
||||
int iTotal = 0, iErrors = 0;
|
||||
char *sAreas, *fAreas, *newdir, *temp;
|
||||
DIR *dp;
|
||||
@ -193,9 +193,11 @@ void Check(void)
|
||||
* Now start checking the files in the filedatabase
|
||||
* against the contents of the directory.
|
||||
*/
|
||||
inArea = 0;
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
|
||||
iTotal++;
|
||||
inArea++;
|
||||
sprintf(newdir, "%s/%s", area.Path, file.LName);
|
||||
|
||||
if (file_exist(newdir, R_OK)) {
|
||||
@ -248,6 +250,8 @@ void Check(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inArea == 0)
|
||||
Syslog('+', "Warning: area %d (%s) is empty", i, area.Name);
|
||||
|
||||
/*
|
||||
* Check files in the directory against the database.
|
||||
|
@ -225,9 +225,6 @@ void Kill(void)
|
||||
unlink(sTemp);
|
||||
chmod(fAreas, 006600);
|
||||
}
|
||||
if (!FilesLeft) {
|
||||
Syslog('+', "Warning: area %d (%s) is empty", i, area.Name);
|
||||
}
|
||||
} else
|
||||
fclose(pFile);
|
||||
|
||||
|
@ -132,8 +132,26 @@ void Move(int From, int To, char *File)
|
||||
while (fread(&fdb, sizeof(fdb), 1, fp1) == 1) {
|
||||
if (strcmp(fdb.LName, File))
|
||||
fwrite(&fdb, sizeof(fdb), 1, fp2);
|
||||
else
|
||||
else {
|
||||
rc = AddFile(fdb, To, topath, frompath);
|
||||
if (rc) {
|
||||
/*
|
||||
* Try to move thumbnail if it exists
|
||||
*/
|
||||
unlink(frompath);
|
||||
free(frompath);
|
||||
free(topath);
|
||||
frompath = xstrcpy(area.Path);
|
||||
frompath = xstrcat(frompath, (char *)"/.");
|
||||
frompath = xstrcat(frompath, File);
|
||||
topath = xstrcpy(area.Path);
|
||||
topath = xstrcat(topath, (char *)"/.");
|
||||
topath = xstrcat(topath, File);
|
||||
if (file_exist(frompath, R_OK) == 0) {
|
||||
file_mv(frompath, topath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp1);
|
||||
fclose(fp2);
|
||||
@ -149,7 +167,6 @@ void Move(int From, int To, char *File)
|
||||
WriteError("$Can't unlink %s", temp1);
|
||||
unlink(temp2);
|
||||
}
|
||||
unlink(frompath);
|
||||
colour(CYAN, BLACK);
|
||||
} else {
|
||||
/*
|
||||
|
@ -579,9 +579,7 @@ int ProcessTic(fa_list *sbl)
|
||||
if (!Get_File_Id()) {
|
||||
if (TIC.TicIn.TotLDesc > 2) {
|
||||
for (i = 0; i < TIC.TicIn.TotLDesc; i++) {
|
||||
strcpy(temp1, TIC.TicIn.LDesc[i]);
|
||||
temp1[48] = '\0';
|
||||
strcpy(TIC.File_Id[i], temp1);
|
||||
strncpy(TIC.File_Id[i], TIC.TicIn.LDesc[i], 48);
|
||||
}
|
||||
TIC.File_Id_Ct = TIC.TicIn.TotLDesc;
|
||||
} else {
|
||||
@ -599,14 +597,18 @@ int ProcessTic(fa_list *sbl)
|
||||
j = 48;
|
||||
while (TDesc[j] != ' ')
|
||||
j--;
|
||||
strncat(TIC.File_Id[TIC.File_Id_Ct], TDesc, j);
|
||||
strncpy(TIC.File_Id[TIC.File_Id_Ct], TDesc, j);
|
||||
Syslog('f', "%2d/%2d: \"%s\"", TIC.File_Id_Ct, j, TIC.File_Id[TIC.File_Id_Ct]);
|
||||
TIC.File_Id_Ct++;
|
||||
k = strlen(TDesc);
|
||||
j++; /* Correct space */
|
||||
for (i = 0; i <= k; i++, j++)
|
||||
TDesc[i] = TDesc[j];
|
||||
if (TIC.File_Id_Ct == 23)
|
||||
break;
|
||||
}
|
||||
strcpy(TIC.File_Id[TIC.File_Id_Ct], TDesc);
|
||||
strncpy(TIC.File_Id[TIC.File_Id_Ct], TDesc, 48);
|
||||
Syslog('f', "%2d/%2d: \"%s\"", TIC.File_Id_Ct, strlen(TIC.File_Id[TIC.File_Id_Ct]), TIC.File_Id[TIC.File_Id_Ct]);
|
||||
TIC.File_Id_Ct++;
|
||||
}
|
||||
}
|
||||
|
23
mbfido/tic.c
23
mbfido/tic.c
@ -165,7 +165,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
{
|
||||
FILE *tfp;
|
||||
char *Temp, *Temp2, *Buf, *Log = NULL;
|
||||
int i, j, rc;
|
||||
int i, j, rc, bufsize;
|
||||
fa_list *sbl = NULL;
|
||||
int DescCnt = FALSE;
|
||||
|
||||
@ -184,10 +184,15 @@ int LoadTic(char *inb, char *tfn)
|
||||
return 1;
|
||||
}
|
||||
|
||||
Temp = calloc(PATH_MAX, sizeof(char));
|
||||
Buf = calloc(PATH_MAX, sizeof(char));
|
||||
if (PATH_MAX > 1024)
|
||||
bufsize = PATH_MAX;
|
||||
else
|
||||
bufsize = 1024;
|
||||
Temp = calloc(bufsize+1, sizeof(char));
|
||||
Buf = calloc(bufsize+1, sizeof(char));
|
||||
Syslog('f', "Tic buffersize %d", bufsize);
|
||||
|
||||
while ((fgets(Buf, PATH_MAX -1, tfp)) != NULL) {
|
||||
while ((fgets(Buf, bufsize, tfp)) != NULL) {
|
||||
/*
|
||||
* Remove all garbage from the .TIC file.
|
||||
*/
|
||||
@ -200,10 +205,10 @@ int LoadTic(char *inb, char *tfn)
|
||||
}
|
||||
Temp[j] = '\0';
|
||||
|
||||
if (strlen(Temp) > 255) {
|
||||
Syslog('+', "Truncating TIC line of %d characters", strlen(Temp));
|
||||
Temp[255] = '\0';
|
||||
}
|
||||
// if (strlen(Temp) > 255) {
|
||||
// Syslog('+', "Truncating TIC line of %d characters", strlen(Temp));
|
||||
// Temp[255] = '\0';
|
||||
// }
|
||||
|
||||
Syslog('f', "TIC: %s", Temp);
|
||||
if (strncasecmp(Temp, "hatch", 5) == 0) {
|
||||
@ -251,7 +256,7 @@ int LoadTic(char *inb, char *tfn)
|
||||
|
||||
} else if (strncasecmp(Temp, "desc ", 5) == 0) {
|
||||
if (!DescCnt) {
|
||||
strncpy(TIC.TicIn.Desc, Temp+5, 255);
|
||||
strncpy(TIC.TicIn.Desc, Temp+5, 1023);
|
||||
strncpy(T_File.Desc, TIC.TicIn.Desc, 255);
|
||||
DescCnt = TRUE;
|
||||
} else {
|
||||
|
@ -17,7 +17,7 @@ typedef struct _tic_in {
|
||||
char Created[81]; /* Created text */
|
||||
char Path[25][81]; /* Travelled path */
|
||||
int TotPath; /* Nr of pathlines */
|
||||
char Desc[256]; /* Short description */
|
||||
char Desc[1024]; /* Short description */
|
||||
char Magic[21]; /* Magic alias */
|
||||
char Crc[9]; /* CRC of file */
|
||||
char Pw[21]; /* Password */
|
||||
|
@ -173,7 +173,7 @@ void ReCalcCrc(char *fn)
|
||||
int Get_File_Id()
|
||||
{
|
||||
char *temp;
|
||||
char Desc[256];
|
||||
char Desc[1024];
|
||||
FILE *fp;
|
||||
int i, j, lines = 0;
|
||||
|
||||
@ -190,7 +190,7 @@ int Get_File_Id()
|
||||
/*
|
||||
* Read no more then 25 lines.
|
||||
*/
|
||||
while (((fgets(Desc, 255, fp)) != NULL) && (TIC.File_Id_Ct < 25)) {
|
||||
while (((fgets(Desc, 1023, fp)) != NULL) && (TIC.File_Id_Ct < 25)) {
|
||||
lines++;
|
||||
/*
|
||||
* Check if the FILE_ID.DIZ is in a normal layout.
|
||||
@ -201,6 +201,8 @@ int Get_File_Id()
|
||||
if (strlen(Desc) > 51) {
|
||||
fclose(fp);
|
||||
unlink(temp);
|
||||
for (i = 0; i < 25; i++)
|
||||
TIC.File_Id[i][0] = '\0';
|
||||
TIC.File_Id_Ct = 0;
|
||||
Syslog('f', "FILE_ID.DIZ line %d is %d chars", lines, strlen(Desc));
|
||||
Syslog('!', "Trashing illegal formatted FILE_ID.DIZ");
|
||||
@ -211,17 +213,21 @@ int Get_File_Id()
|
||||
if (strlen(Desc) > 0) {
|
||||
j = 0;
|
||||
for (i = 0; i < strlen(Desc); i++) {
|
||||
if ((Desc[i] >= ' ') || (Desc[i] < 0)) {
|
||||
if (isprint(Desc[i])) {
|
||||
TIC.File_Id[TIC.File_Id_Ct][j] = Desc[i];
|
||||
j++;
|
||||
if (j > 47)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (j >= 48)
|
||||
TIC.File_Id[TIC.File_Id_Ct][48] = '\0';
|
||||
else
|
||||
/*
|
||||
* Remove trailing spaces
|
||||
*/
|
||||
while (j && isspace(TIC.File_Id[TIC.File_Id_Ct][j-1]))
|
||||
j--;
|
||||
TIC.File_Id[TIC.File_Id_Ct][j] = '\0';
|
||||
|
||||
Syslog('f', "%2d/%2d: \"%s\"", TIC.File_Id_Ct, j, TIC.File_Id[TIC.File_Id_Ct]);
|
||||
TIC.File_Id_Ct++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user