-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
base: main
Are you sure you want to change the base?
drivers: mdio: shell: Fix various buffer overflows #93257
Conversation
Related: #93254 |
839b05b
to
9f97e96
Compare
Need to check argument count to avoid buffer overflows and crashes. Signed-off-by: Cla Mattia Galliard <[email protected]>
9f97e96
to
1b4dd13
Compare
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
if (ret < 0) { | ||
return ret; | ||
} | ||
|
||
if (argc < 5) { |
There was a problem hiding this comment.
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.
zephyr/include/zephyr/shell/shell.h
Lines 531 to 532 in 72dc0e5
* @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. |
There was a problem hiding this 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),
Need to check argument count to avoid buffer overflows and crashes.