[CID-32919, 33501] Fix bug
[platform/upstream/connman.git] / vpn / plugins / ipsec.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);