FILE *f = NULL;
char js_path[1024] = {'\0',};
+ char buf[256] = {'\0',};
+
snprintf(js_path, 1024, "%s/%s", VC_WEBVIEW_JS_PATH, filename);
LOGD("===path (%s)", js_path);
f = fopen(js_path, "r");
if (NULL == f) {
- LOGE("Couldn't open %s - %s", filename, strerror(errno));
+ LOGE("Couldn't open %s - %s", filename, strerror_r(errno, buf, 256));
return NULL;
}
fseek(f, 0, SEEK_END);
- long int fsize = ftell(f);
+ unsigned int fsize = (unsigned int)ftell(f);
+ if (fsize > 4294967295) {
+ LOGE("Wrong file size");
+ fclose(f);
+ return NULL;
+ }
fseek(f, 0, SEEK_SET);
char *script = new char [fsize + 1];
- long int ret = fread(script, 1, fsize, f);
+ unsigned int ret = fread(script, 1, fsize, f);
if (ret != fsize) {
LOGE("Couldn't read vc-webview.js file %d, %d", fsize, ret);
fclose(f);
FILE *f = NULL;
file_name = host_name + path_name + ".js";
char js_path[1024] = {'\0',};
+ char buf[256] = {'\0',};
+
snprintf(js_path, 1024, "%s/%s", VC_WEBVIEW_CUSTOM_PATH, file_name.c_str());
LOGD("=== path (%s)", js_path);
f = fopen(js_path, "r");
if (NULL == f) {
- LOGE("Couldn't open %s - %s", file_name.c_str(), strerror(errno));
+ LOGE("Couldn't open %s - %s", file_name.c_str(), strerror_r(errno, buf, 256));
file_name = host_name + ".js";
snprintf(js_path, 1024, "%s/%s", VC_WEBVIEW_CUSTOM_PATH, file_name.c_str());
if (m_custom_name.compare(file_name) != 0) {
fseek(f, 0, SEEK_END);
- long int fsize = ftell(f);
+ unsigned int fsize = (unsigned int)ftell(f);
+ if (fsize > 4294967295) {
+ LOGE("Wrong file size");
+ fclose(f);
+ return;
+ }
fseek(f, 0, SEEK_SET);
char *script = new char [fsize + 1];
- long int ret = fread(script, 1, fsize, f);
+ unsigned int ret = fread(script, 1, fsize, f);
if (ret != fsize) {
LOGE("Couldn't read vc-webview.js file %d, %d", fsize, ret);
fclose(f);
delete [] script;
return;
}
- fclose(f);
script[fsize] = '\0';
delete [] m_custom_script;
}
ewk_view_script_execute((Evas_Object*)data, m_custom_script, __js_script_loading_result_cb, (void*)"custom");
+
+ fclose(f);
}
void VCWebView::vc_webview_set_view(Evas_Object *ewk_view)
ewk_view_script_execute(m_ewk_view, execute.c_str(), __js_script_loading_result_cb, (void*)"REMOVE_TOOLTIP");
}
-#endif
\ No newline at end of file
+#endif