[CID-32919, 33501] Fix bug 15/154415/1
authorchleun.moon <chleun.moon@samsung.com>
Tue, 10 Oct 2017 07:31:22 +0000 (16:31 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Tue, 10 Oct 2017 07:32:11 +0000 (16:32 +0900)
Change-Id: I8fc3c40c8a2cf3d9e5fb840796d0f0bf0b66a072
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
vpn/plugins/ipsec.c
vpn/plugins/vici-client.c

index fa9dc7a..617830c 100644 (file)
@@ -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);
index dc651cf..9422894 100644 (file)
@@ -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);