From: Tobias Brunner Date: Wed, 2 Jul 2014 10:03:36 +0000 (+0200) Subject: optionsfrom: Properly handle errors when determining file size X-Git-Tag: 5.2.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=831045ef45a9f90c1713f14a23f16b3ea54ac117;p=thirdparty%2Fstrongswan.git optionsfrom: Properly handle errors when determining file size --- diff --git a/src/libstrongswan/utils/optionsfrom.c b/src/libstrongswan/utils/optionsfrom.c index 117071351c..6f721c9efc 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 */