-
Notifications
You must be signed in to change notification settings - Fork 162
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
[BUG] prvTCPReturnPacket_IPV4() dereferences pxNetworkBuffer outside its null pointer check #1136
Comments
Thanks for reporting. We'll have the team go through the code flow you mentioned above and see if any action needs to be taken |
Thanks for sharing this detailed report. Your assessment regarding Regarding
Hence I believe the 2nd case is indeed a false positive as you suggested. |
Thanks!
My thinking was that it is enough to observe that xSocketValid() only returns pdTRUE if its argument is non-null. Clang-tidy can't see into |
Will you be interested in creating a PR to fix this issue, or would you prefer that we create one? |
I would be delighted! I'm writing a commit. It looks like the corresponding *_IPv6 function has the same problem. I'll check if it does and then include that too. I can also move the variables into the scope. In a separate commit. |
With merged PR, I am closing this issue. |
This applies to the latest release (V4.1.0) as well as origin/HEAD as of writing.
Clang-tidy (16 and 18) complains about a couple of possible null pointer dereferences in this repository, and I think it is right about one of them. They are of the form of a null pointer check (hinting that it can be NULL) and a dereference outside the check that dereferences it anyway.
function prvTCPReturnPacket_IPV4(), variable pxNetworkBuffer:
source/FreeRTOS_TCP_Transmission_IPv4.c:147:44: warning: Access to field 'pucEthernetBuffer' results in a dereference of a null pointer (loaded from variable 'pxNetworkBuffer'
This is the one I think clang-tidy is right about. Here, the unguarded dereference is accompanied by null pointer checks both before and after:
Interestingly, the section above this would have made sure it isn't a null pointer if it wasn't for assigning it again here. If the assignment here (in the ipconfigZERO_COPY_TX_DRIVER section) is to uphold the same guarrantee, it is missing some error handling.
function prvSendDHCPRequest(), variable EP_DHCPData.xDHCPSocket:
This must be a false positive, but I'll include it.
Clang is looking across 3 funciton calls to build a case for how this pointer can be null at the place of dereference,
but ignores the possibility that
xSocketValid()
can contain the crucial null pointer check,which it does.
In function vDHCPProcess:
In function vDHCPProcessEndPoint:
In function prvSendDHCPRequest:
The text was updated successfully, but these errors were encountered: