Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential bug CWE-670 virtual function was overridden incorrectly Err… #5907

Open
wants to merge 1 commit into
base: sprint/24Q4
Choose a base branch
from

Conversation

hridhya-narayanan-infosys

…or found during static code analysis in webkitbrowser-plugin

Below warning is raised during Static Code Analysis (SCA) using PVS-Studio in webkitbrowser-plugin component at https://github.com/rdkcentral/rdkservices/blob/sprint/24Q4/WebKitBrowser/WebKitImplementation.cpp#L2712

struct ExitJob : public Core::IDispatch
{
virtual void Dispatch() { exit(1); }

[CWE-670] V762: It is possible a virtual function was overridden incorrectly. See first argument of function 'Dispatch' in derived class 'ExitJob' and base class 'IDispatchType'.

The warning is raised in https://github.com/rdkcentral/rdkservices/blob/sprint/24Q4/WebKitBrowser/WebKitImplementation.cpp#L2712
virtual void Dispatch() { exit(1); }

This warning suggests a mismatch between the Dispatch() function signature in ExitJob and the virtual function it is intended to override.

From Thunder Interface code(https://github.com/rdkcentral/Thunder/blob/R4/Source/core/IAction.h) I could see struct IDispatch is inherited from IDispatchType template.
Here there are two templates IDispatchType which includes Dispatch virtual function - one with argument and other without any argument.

Seems this issue arises because the Dispatch() method in ExitJob does not use the override keyword, making a chance of mismtach with the the virtual function from the base class.

By marking the Dispatch() method in ExitJob as an override of the virtual Dispatch() method in the base class I could see the warning is getting resolved.

So wanted to address this warning with fix.

…or found during static code analysis in webkitbrowser-plugin
@CLAassistant
Copy link

CLAassistant commented Dec 3, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants