Skip to content

drivers: mdio: shell: Fix various buffer overflows #93257

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clamattia
Copy link
Contributor

Need to check argument count to avoid buffer overflows and crashes.

@clamattia
Copy link
Contributor Author

Related: #93254

Need to check argument count to avoid buffer overflows and crashes.

Signed-off-by: Cla Mattia Galliard <[email protected]>
@clamattia clamattia force-pushed the hotfix/mdio_shell_buffer_overflow branch from 9f97e96 to 1b4dd13 Compare July 17, 2025 08:42
Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

if (ret < 0) {
return ret;
}

if (argc < 5) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and the below new checks are not needed as the commands take no optional arguments and therefore this is already checked by the shell.

* @note If a command will be called with wrong number of arguments shell will
* print an error message and command handler will not be called.

Copy link
Contributor

@tpambor tpambor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the number of mandatory arguments for the scan command should be fixed, currently 1 but should be 2, scan and device.

	SHELL_CMD_ARG(scan, &dsub_device_name,
		"Scan MDIO bus for devices: scan <device> [<reg_addr>]",
		cmd_mdio_scan, 1, 1),

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

Successfully merging this pull request may close these issues.

5 participants