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 E… #6136

Open
wants to merge 1 commit into
base: sprint/25Q1
Choose a base branch
from

Conversation

hridhya-narayanan-infosys
Copy link

@hridhya-narayanan-infosys hridhya-narayanan-infosys commented Mar 14, 2025

…rror 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/25Q1/WebKitBrowser/WebKitImplementation.cpp#L2717

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/25Q1/WebKitBrowser/WebKitImplementation.cpp#L2717
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.

@hridhya-narayanan-infosys hridhya-narayanan-infosys force-pushed the hridhya-narayanan-infosys/SQ_issue_Virtual-function_override_sprint_25Q1 branch 4 times, most recently from 48026e0 to b1d424f Compare March 24, 2025 13:04
…rror found during static code analysis in webkitbrowser-plugin
@hridhya-narayanan-infosys hridhya-narayanan-infosys force-pushed the hridhya-narayanan-infosys/SQ_issue_Virtual-function_override_sprint_25Q1 branch from b1d424f to b36acc4 Compare March 25, 2025 04:49
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