summaryrefslogtreecommitdiff
path: root/src/libstrongswan/utils/optionsfrom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/utils/optionsfrom.c')
-rw-r--r--src/libstrongswan/utils/optionsfrom.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libstrongswan/utils/optionsfrom.c b/src/libstrongswan/utils/optionsfrom.c
index e51780290..5fd4cfd4d 100644
--- a/src/libstrongswan/utils/optionsfrom.c
+++ b/src/libstrongswan/utils/optionsfrom.c
@@ -67,7 +67,6 @@ METHOD(options_t, from, bool,
int newargc;
int next; /* place for next argument */
char **newargv;
- size_t bytes;
chunk_t src, line, token;
bool good = TRUE;
int linepos = 0;
@@ -99,7 +98,14 @@ METHOD(options_t, from, bool,
src.ptr = this->buffers[this->nuses] = malloc(src.len + 1);
/* read the whole file into a chunk */
- bytes = fread(src.ptr, 1, src.len, fd);
+ if (fread(src.ptr, 1, src.len, fd) != src.len)
+ {
+ DBG1(DBG_LIB, "optionsfrom: unable to read file '%s': %s",
+ filename, strerror(errno));
+ free(src.ptr);
+ fclose(fd);
+ return FALSE;
+ }
fclose(fd);
if (this->room)