FreeRTOS / FreeRTOS-Plus-TCP

FreeRTOS-Plus-TCP library repository. +TCP files only. Submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos.
MIT License
146 stars 159 forks source link

Tcp transmission: Fix nullptr dereference #1137

Closed anordal closed 5 months ago

anordal commented 5 months ago

Description

The first commit moves the initialization of pxIPHeader. This fixes a possible nullpointer dereference.

~The second commit reduces the scope of pxIPHeader and other local variables.~ Dropped.

Test Steps

I am using this CMake hack to compile my project with clang-tidy:

# Setting *_CLANG_TIDY tells CMake to insert itself as a compiler wrapper,
# underneath Ccache, that also runs Clang-tidy. Thus, Clang-tidy is rerun
# whenever the compiler is, as determined by Ninja and Ccache. For Ccache
# invalidation to work when settings are changed, the settings must therefore be
# in the arguments, not some ".clang-tidy" file that Ccache doesn't know about.
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
    set(tidy_checks
        -clang-analyzer-security.insecureAPI.*
        -clang-analyzer-deadcode.DeadStores
        # -clang-analyzer-core.NullDereference
    )
    string(JOIN "," tidy_checks_str ${tidy_checks})
    set(CMAKE_C_CLANG_TIDY
        clang-tidy
        --use-color
        --checks=${tidy_checks_str}
        --warnings-as-errors=*,${tidy_checks_str}
    )
endif()

Checklist:

Related Issue

1136

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

tony-josi-aws commented 5 months ago

@anordal , thanks for creating this PR