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

bluetooth: shell: Lots of checks of type (unsigned < 0) which is bogus #54101

Closed
finikorg opened this issue Jan 25, 2023 · 7 comments · Fixed by #54165
Closed

bluetooth: shell: Lots of checks of type (unsigned < 0) which is bogus #54101

finikorg opened this issue Jan 25, 2023 · 7 comments · Fixed by #54165
Assignees
Labels
area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@finikorg
Copy link
Collaborator

Unsigned cannot be less then zero so there is no need to check for it.

Example of checks:

param.adv_sid = strtol(argv[3], NULL, 0);
if (param.adv_sid < 0 || param.adv_sid > 0x0F) {

or
param.pa_sync = strtol(argv[4], NULL, 0);
if (param.pa_sync < 0 || param.pa_sync > 1) {

etc

@finikorg finikorg added bug The issue is a bug, or the PR is fixing a bug area: Bluetooth labels Jan 25, 2023
@finikorg finikorg assigned finikorg, Thalley and jhedberg and unassigned finikorg Jan 25, 2023
@Thalley
Copy link
Collaborator

Thalley commented Jan 25, 2023

@finikorg Do you have a way to generate the full list?

It's quite an effort if someone manually have to go through each strtoX in the shell modules to verify every single parameter.

@finikorg
Copy link
Collaborator Author

finikorg commented Jan 25, 2023

No, I cannot, but I think it does make sense to check them all, there are other bugs like checking (uint32 > UINT32_MAX), etc.
I am sure all tools like Klocwork, coverity, etc can help with that.

@Thalley
Copy link
Collaborator

Thalley commented Jan 25, 2023

No, I cannot, but I think it does make sense to check them all, there are other bugs like checking (uint32 > UINT32_MAX), etc

You may be right :) Looks like we have a total of 286 calls to strtoX that needs to be checked.

I am sure all tools like Klocwork, coverity, etc can help with that.
Except none of those are free to use :(

There are several discussions going on with using cppcheck or other free tools, but I wonder if they also catch these :)

But yeah, without a predefined list, fixing this issue may take quite a while, as it is low priority but high effort.

I can put in the work to fix this for the audio shell modules.

@laurenmurphyx64 laurenmurphyx64 added the priority: low Low impact/importance bug label Jan 26, 2023
@Thalley
Copy link
Collaborator

Thalley commented Jan 27, 2023

Fixing all LE Audio (and ISO) shell strtoX in #54165

@Thalley
Copy link
Collaborator

Thalley commented Jan 29, 2023

@finikorg I think I fixed all the bugs in the LE audio files. Please review :)

@Thalley
Copy link
Collaborator

Thalley commented Feb 20, 2023

@finikorg Can you verify if there are still some missing in the non-LE Audio files?

@finikorg
Copy link
Collaborator Author

Can you verify if there are still some missing in the non-LE Audio files?

Thanks. I think all fixed, I let you know if there are some bugs left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants