1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2024-12-26 11:30:03 +05:30

extol.c: add file size limit

This commit is contained in:
Intel A80486DX2-66 2024-03-09 12:14:56 +03:00
parent 4ae64ebf95
commit 267b869440
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -16,12 +16,15 @@ enum
} EXTOL_MODE;
#define EXTOL_PROTOTYPE "int extol(FILE* f)"
#define EXTOL_FILE_NAME "extol.txt"
#define EXTOL_FILE_LIMIT 128
int
extol (FILE *f)
{
static bool spec_run = true;
int result;
off_t size;
if (spec_run == false)
{
@ -38,6 +41,21 @@ extol (FILE *f)
exit (EXIT_FAILURE);
}
fseek (fs, 0L, SEEK_END);
size = ftello (fs);
if (size == -1)
{
perror ("ftello");
exit (EXIT_FAILURE);
}
else if (size > EXTOL_FILE_LIMIT)
{
FILE *new_fs = freopen (EXTOL_FILE_NAME, "w", fs);
if (new_fs == NULL)
{
perror ("freopen");
exit (EXIT_FAILURE);
}
}
result = extol (fs);
for (result <<= 4, result &= ~15; (result & 15) != 15; result++)
fputc ('=', fs);