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

Unsafe type assertion #772

Open
burkeartem opened this issue Nov 22, 2023 · 0 comments
Open

Unsafe type assertion #772

burkeartem opened this issue Nov 22, 2023 · 0 comments

Comments

@burkeartem
Copy link

In line 76 value may have type different from '*bool'.

The type assertion assumes that value is not zero and that value stores a value of type *bool, otherwise the command will cause panic. If value is checked for zero in line 73, then apparently a check for the *bool type is performed in line 76, but such a check is incorrect, because it will cause panic if the value type does not match the *bool type.

I think it would be safer to use the following construction:
if _, ok :=value.(*bool); ok { ... }

Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.
Author A. Burke.

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

No branches or pull requests

1 participant