aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fileutils.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/fileutils.c b/src/fileutils.c
index 7f85ba8..b219c07 100644
--- a/src/fileutils.c
+++ b/src/fileutils.c
@@ -29,6 +29,13 @@ int file_get_content(const char *filepath, char **data, long *size) {
return -1;
}
+ int fd = fileno(file);
+ struct stat s;
+ if(fstat(fd, &s) == -1 || !S_ISREG(s.st_mode)) {
+ fclose(file);
+ return -1;
+ }
+
fseek(file, 0, SEEK_END);
*size = ftell(file);
if(*size == -1) {