From bb338a28df06f54e05eb0a502550211189c28d1c Mon Sep 17 00:00:00 2001 From: Chandan Padhi Date: Thu, 5 Mar 2020 15:27:33 +0530 Subject: [PATCH] [Coverity] Fix coverity defects This commit also includes changes from https://review.tizen.org/gerrit/#/c/213680/. Change-Id: Iccccadb1cf718bd102ab51e80a656cec87416107 Signed-off-by: Chandan Padhi --- .../browser/ssl_host_state_delegate_efl.cc | 22 +++------------- .../browser/ssl_host_state_delegate_efl.h | 5 +--- .../ewk/efl_integration/devtools_delegate_efl.cc | 4 +-- .../renderer/print_web_view_helper_efl.cc | 12 ++++++--- .../url_request_context_getter_efl.cc | 18 +++++++------ .../ewk/efl_integration/wrt/wrt_widget_host.cc | 7 ++++- tizen_src/ewk/ubrowser/logger.cc | 30 ++++++++++------------ 7 files changed, 44 insertions(+), 54 deletions(-) diff --git a/tizen_src/ewk/efl_integration/browser/ssl_host_state_delegate_efl.cc b/tizen_src/ewk/efl_integration/browser/ssl_host_state_delegate_efl.cc index 2a1935e3..9375715 100644 --- a/tizen_src/ewk/efl_integration/browser/ssl_host_state_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/ssl_host_state_delegate_efl.cc @@ -11,16 +11,6 @@ using content::SSLHostStateDelegate; namespace content { namespace internal { -net::SHA256HashValue getChainFingerprint256(const net::X509Certificate& cert) { -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - net::SHA256HashValue fingerprint = - net::X509Certificate::CalculateChainFingerprint256( - cert.os_cert_handle(), cert.GetIntermediateCertificates()); -#else - net::SHA256HashValue fingerprint; -#endif - return fingerprint; -} CertPolicy::CertPolicy() { } @@ -33,16 +23,13 @@ CertPolicy::~CertPolicy() { // in the saved CertStatus. bool CertPolicy::Check(const net::X509Certificate& cert, net::CertStatus error) const { -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - net::SHA256HashValue fingerprint = getChainFingerprint256(cert); - std::map::const_iterator allowed_iter = + net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256(); + std::map::const_iterator allowed_iter = allowed_.find(fingerprint); if ((allowed_iter != allowed_.end()) && (allowed_iter->second & error) && ((allowed_iter->second & error) == error)) { return true; } -#endif return false; } @@ -50,10 +37,8 @@ void CertPolicy::Allow(const net::X509Certificate& cert, net::CertStatus error) { // If this same cert had already been saved with a different error status, // this will replace it with the new error status. -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - net::SHA256HashValue fingerprint = getChainFingerprint256(cert); + net::SHA256HashValue fingerprint = cert.CalculateChainFingerprint256(); allowed_[fingerprint] = error; -#endif } } // namespace internal @@ -106,7 +91,6 @@ void SSLHostStateDelegateEfl::RevokeUserAllowExceptions( } bool SSLHostStateDelegateEfl::HasAllowException(const std::string& host) const { - NOTIMPLEMENTED(); return false; } diff --git a/tizen_src/ewk/efl_integration/browser/ssl_host_state_delegate_efl.h b/tizen_src/ewk/efl_integration/browser/ssl_host_state_delegate_efl.h index b3a19fb2..5e9992d 100644 --- a/tizen_src/ewk/efl_integration/browser/ssl_host_state_delegate_efl.h +++ b/tizen_src/ewk/efl_integration/browser/ssl_host_state_delegate_efl.h @@ -32,10 +32,7 @@ class CertPolicy { private: // The set of fingerprints of allowed certificates. -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup - std::map - allowed_; -#endif + std::map allowed_; }; } // namespace internal diff --git a/tizen_src/ewk/efl_integration/devtools_delegate_efl.cc b/tizen_src/ewk/efl_integration/devtools_delegate_efl.cc index 49caec4..c88678c 100644 --- a/tizen_src/ewk/efl_integration/devtools_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/devtools_delegate_efl.cc @@ -86,8 +86,8 @@ DevToolsDelegateEfl::DevToolsDelegateEfl(int port) : port_(0) { int temp_port = 0; std::string port_str = command_line->GetSwitchValueASCII(switches::kRemoteDebuggingPort); - base::StringToInt(port_str, &temp_port); - if (temp_port > 0 && temp_port < 65535) { + if (base::StringToInt(port_str, &temp_port) && (temp_port > 0) && + (temp_port < 65535)) { port = temp_port; } else { DLOG(WARNING) << "Invalid http debugger port number " << temp_port; diff --git a/tizen_src/ewk/efl_integration/renderer/print_web_view_helper_efl.cc b/tizen_src/ewk/efl_integration/renderer/print_web_view_helper_efl.cc index a68026b..67d494d 100644 --- a/tizen_src/ewk/efl_integration/renderer/print_web_view_helper_efl.cc +++ b/tizen_src/ewk/efl_integration/renderer/print_web_view_helper_efl.cc @@ -116,7 +116,9 @@ bool PrintWebViewHelperEfl::RenderPagesForPrint(blink::WebFrame* frame) { const PrintParams& print_params = params.params; blink::WebPrintParams webkit_print_params; ComputeWebKitPrintParamsInDesiredDpi(print_params, &webkit_print_params); -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup +#if defined(EWK_BRINGUP) // FIXME: m67 bringup + return false; +#else int page_count = frame->printBegin(webkit_print_params); gfx::Size print_canvas_size(webkit_print_params.printContentArea.width, webkit_print_params.printContentArea.height); @@ -128,7 +130,9 @@ bool PrintWebViewHelperEfl::RenderPagesForPrint(blink::WebFrame* frame) { bool PrintWebViewHelperEfl::PrintPagesToPdf(blink::WebFrame* frame, int page_count, const gfx::Size& canvas_size) { -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup +#if defined(EWK_BRINGUP) // FIXME: m67 bringup + return false; +#else printing::PdfMetafileSkia metafile(printing::PDF_SKIA_DOCUMENT_TYPE); if (!metafile.Init()) return false; @@ -200,7 +204,9 @@ bool PrintWebViewHelperEfl::PrintPageInternal( PrintParams result; double scale_factor = 1.0f; gfx::Rect canvas_area(canvas_size); -#if !defined(EWK_BRINGUP) // FIXME: m67 bringup +#if defined(EWK_BRINGUP) // FIXME: m67 bringup + return false; +#else // FIXME: cannot convert ‘cc::PaintCanvas*’ to ‘skia::VectorCanvas* {aka // SkCanvas*}’ in initialization skia::VectorCanvas* canvas = metafile->GetVectorCanvasForNewPage( diff --git a/tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc b/tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc index d0854a1..9f37947 100644 --- a/tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc +++ b/tizen_src/ewk/efl_integration/url_request_context_getter_efl.cc @@ -195,17 +195,19 @@ net::URLRequestContext* URLRequestContextGetterEfl::GetURLRequestContext() { ignore_certificate_errors_; if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { int value; - base::StringToInt( - command_line.GetSwitchValueASCII(switches::kTestingFixedHttpPort), - &value); - network_session_params.testing_fixed_http_port = value; + if (base::StringToInt( + command_line.GetSwitchValueASCII(switches::kTestingFixedHttpPort), + &value)) { + network_session_params.testing_fixed_http_port = value; + } } if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { int value; - base::StringToInt( - command_line.GetSwitchValueASCII(switches::kTestingFixedHttpsPort), - &value); - network_session_params.testing_fixed_https_port = value; + if (base::StringToInt(command_line.GetSwitchValueASCII( + switches::kTestingFixedHttpsPort), + &value)) { + network_session_params.testing_fixed_https_port = value; + } } http_network_session_.reset(new net::HttpNetworkSession( diff --git a/tizen_src/ewk/efl_integration/wrt/wrt_widget_host.cc b/tizen_src/ewk/efl_integration/wrt/wrt_widget_host.cc index 5f75ddd..d57a495 100644 --- a/tizen_src/ewk/efl_integration/wrt/wrt_widget_host.cc +++ b/tizen_src/ewk/efl_integration/wrt/wrt_widget_host.cc @@ -34,7 +34,12 @@ bool SendToAllRenderers(IPC::Message* message) { } bool SendToRenderer(int renderer_id, IPC::Message* message) { - return content::RenderProcessHost::FromID(renderer_id)->Send(message); + content::RenderProcessHost* host = + content::RenderProcessHost::FromID(renderer_id); + if (!host) + return false; + + return host->Send(message); } } diff --git a/tizen_src/ewk/ubrowser/logger.cc b/tizen_src/ewk/ubrowser/logger.cc index e2c38fb..373619e 100644 --- a/tizen_src/ewk/ubrowser/logger.cc +++ b/tizen_src/ewk/ubrowser/logger.cc @@ -92,26 +92,25 @@ _make_format(MESSAGE_TYPE type, int add_newline, const char* fmt) { void log_message(MESSAGE_TYPE type, int add_newline, const char* fmt, ...) { - char* msg_fmt = NULL; - va_list list; - - if (!logger_show_trace && type == TRACE) { + if (!logger_show_trace && type == TRACE) return; - } - msg_fmt = _make_format(type, add_newline, fmt); + char* msg_fmt = _make_format(type, add_newline, fmt); + va_list list; va_start(list, fmt); if (msg_fmt == NULL) { vfprintf(stderr, fmt, list); + va_end(list); + return; } - if (type == ERROR) { + if (type == ERROR) vfprintf(stderr, msg_fmt, list); - } else { + else vfprintf(stdout, msg_fmt, list); - } + va_end(list); free(msg_fmt); @@ -119,23 +118,20 @@ log_message(MESSAGE_TYPE type, int add_newline, const char* fmt, ...) { void vlog_message(MESSAGE_TYPE type, int add_newline, const char* fmt, va_list vl) { - char* msg_fmt = NULL; - - if (!logger_show_trace && type == TRACE) { + if (!logger_show_trace && type == TRACE) return; - } - msg_fmt = _make_format(type, add_newline, fmt); + char* msg_fmt = _make_format(type, add_newline, fmt); if (msg_fmt == NULL) { vfprintf(stderr, fmt, vl); + return; } - if (type == ERROR) { + if (type == ERROR) vfprintf(stderr, msg_fmt, vl); - } else { + else vfprintf(stdout, msg_fmt, vl); - } free(msg_fmt); } -- 2.7.4