From 88e1178c2cbc87a27ada13569f80cd46f9d44aa5 Mon Sep 17 00:00:00 2001 From: "chleun.moon" Date: Tue, 10 Oct 2017 16:31:22 +0900 Subject: [PATCH] [CID-32919, 33501] Fix bug Change-Id: I8fc3c40c8a2cf3d9e5fb840796d0f0bf0b66a072 Signed-off-by: Cheoleun Moon --- vpn/plugins/ipsec.c | 6 ++++++ vpn/plugins/vici-client.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/vpn/plugins/ipsec.c b/vpn/plugins/ipsec.c index fa9dc7a..617830c 100644 --- a/vpn/plugins/ipsec.c +++ b/vpn/plugins/ipsec.c @@ -796,6 +796,12 @@ static char *load_file_from_path(const char *path) } fd = fileno(fp); + if (fd == -1) { + connman_error("fp is not a valid stream"); + fclose(fp); + return NULL; + } + fstat(fd, &st); file_size = st.st_size; file_buff = g_try_malloc0(sizeof(char)*st.st_size); diff --git a/vpn/plugins/vici-client.c b/vpn/plugins/vici-client.c index dc651cf..9422894 100644 --- a/vpn/plugins/vici-client.c +++ b/vpn/plugins/vici-client.c @@ -280,6 +280,12 @@ static char *load_cert_from_path(const char *path) } fd = fileno(fp); + if (fd == -1) { + connman_error("fp is not a valid stream"); + fclose(fp); + return NULL; + } + fstat(fd, &st); file_size = st.st_size; file_buff = g_try_malloc0(sizeof(char)*st.st_size); -- 2.7.4