aboutsummaryrefslogtreecommitdiffstats
path: root/src/libimcv/imc
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2016-03-11 14:22:19 +0100
committerTobias Brunner <tobias@strongswan.org>2016-03-11 15:23:17 +0100
commit8c3bcebaa69e5b4eba7d65d4d9f45f67b8e77931 (patch)
treedee7a629e282410287f3364c7b8e615c84391174 /src/libimcv/imc
parent755d076fecef626559152655f46d6035ab6edf43 (diff)
downloadstrongswan-8c3bcebaa69e5b4eba7d65d4d9f45f67b8e77931.tar.bz2
strongswan-8c3bcebaa69e5b4eba7d65d4d9f45f67b8e77931.tar.xz
imc-os: Correctly check return value of ftell(2)
Diffstat (limited to 'src/libimcv/imc')
-rw-r--r--src/libimcv/imc/imc_os_info.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libimcv/imc/imc_os_info.c b/src/libimcv/imc/imc_os_info.c
index 0a094eb23..7f2135ee2 100644
--- a/src/libimcv/imc/imc_os_info.c
+++ b/src/libimcv/imc/imc_os_info.c
@@ -383,6 +383,7 @@ static bool extract_platform_info(os_type_t *type, chunk_t *name,
FILE *file;
u_char buf[BUF_LEN], *pos = buf;
int len = BUF_LEN - 1;
+ long file_len;
os_type_t os_type = OS_TYPE_UNKNOWN;
chunk_t os_name = chunk_empty;
chunk_t os_version = chunk_empty;
@@ -425,7 +426,14 @@ static bool extract_platform_info(os_type_t *type, chunk_t *name,
/* read release file into buffer */
fseek(file, 0, SEEK_END);
- len = min(ftell(file), len);
+ file_len = ftell(file);
+ if (file_len < 0)
+ {
+ DBG1(DBG_IMC, "failed to determine size of \"%s\"", releases[i]);
+ fclose(file);
+ return FALSE;
+ }
+ len = min(file_len, len);
rewind(file);
buf[len] = '\0';
if (fread(buf, 1, len, file) != len)