-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[Coverity CID: 220541] Dereference before null check in subsys/net/lib/capture/capture.c #34000
Comments
Do not try to set or get the interface MTU if the interface pointer is NULL. Coverity-CID: 220541 Fixes zephyrproject-rtos#34000 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
I think that there should be
and
|
I considered that solution but decided to do it differently. If both IPv4 and IPv6 are enabled, there would be the same check twice which is unnecessary. So I placed the remote_iface NULL check after the IPv4/IPv6 checks. |
There would be two checks in compiled binary, yes. But it is hard to do without it before using
|
And as noted above, this check would be twice in compiled binary. However for a single function invocation, there would be just a single check. |
What about calculating ip headers first (based on IPv4 vs IPv6):
or
and then
|
The mtu value (if <0) is not used as we bail out if remote_iface is NULL. |
Do not try to set or get the interface MTU if the interface pointer is NULL. Coverity-CID: 220541 Fixes #34000 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Static code scan issues found in file:
https://github.com/zephyrproject-rtos/zephyr/tree/b86f7addae05add0db45d9b528854235fbb93a48/subsys/net/lib/capture/capture.c#L342
Category: Null pointer dereferences
Function:
net_capture_setup
Component: Networking
CID: 220541
Details:
zephyr/subsys/net/lib/capture/capture.c
Line 342 in b86f7ad
Please fix or provide comments in coverity using the link:
https://scan9.coverity.com/reports.htm#v29271/p12996
Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the CODEOWNERS file.
The text was updated successfully, but these errors were encountered: