mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-27 05:40:17 +05:30
extol.c: add file size limit
This commit is contained in:
parent
4ae64ebf95
commit
267b869440
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user