aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2014-07-02 12:03:36 +0200
committerTobias Brunner <tobias@strongswan.org>2014-07-02 12:38:45 +0200
commit831045ef45a9f90c1713f14a23f16b3ea54ac117 (patch)
tree9d503bfef825580c77dd277ab751ea71573f01c1
parente44223dbcc3ec9b7a8f77c5174f462bd6cae805b (diff)
downloadstrongswan-831045ef45a9f90c1713f14a23f16b3ea54ac117.tar.bz2
strongswan-831045ef45a9f90c1713f14a23f16b3ea54ac117.tar.xz
optionsfrom: Properly handle errors when determining file size
-rw-r--r--src/libstrongswan/utils/optionsfrom.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libstrongswan/utils/optionsfrom.c b/src/libstrongswan/utils/optionsfrom.c
index 117071351..6f721c9ef 100644
--- a/src/libstrongswan/utils/optionsfrom.c
+++ b/src/libstrongswan/utils/optionsfrom.c
@@ -90,8 +90,13 @@ METHOD(options_t, from, bool,
}
/* determine the file size */
- fseek(fd, 0, SEEK_END);
- src.len = ftell(fd);
+ if (fseek(fd, 0, SEEK_END) == -1 || (src.len = ftell(fd)) == -1)
+ {
+ DBG1(DBG_LIB, "optionsfrom: unable to determine size of '%s': %s",
+ filename, strerror(errno));
+ fclose(fd);
+ return FALSE;
+ }
rewind(fd);
/* allocate one byte more just in case of a missing final newline */