summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/ParseFile.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/util/ParseFile.c b/src/util/ParseFile.c
index a80e1df8..751bed98 100644
--- a/src/util/ParseFile.c
+++ b/src/util/ParseFile.c
@@ -316,6 +316,7 @@ int main(int argc, char *argv[])
static char *ReadFile(FILE *file, unsigned long *filesize)
{
char *buffer;
+ size_t bytes_read;
if (!file)
{
@@ -334,7 +335,13 @@ static char *ReadFile(FILE *file, unsigned long *filesize)
return NULL;
}
/* Read file into buffer and return */
- fread(buffer, *filesize, 1, file);
+ bytes_read = fread(buffer, *filesize, 1, file);
+ if (bytes_read != *filesize)
+ {
+ fprintf(stderr, "File size changed while reading.\n");
+ free(buffer);
+ return NULL;
+ }
/* Protect buffer for string operations */
buffer[*filesize] = '\0';
return buffer;