fix(transport): fix SASL null pointer check and build config#35221
fix(transport): fix SASL null pointer check and build config#35221
Conversation
There was a problem hiding this comment.
Code Review
This pull request enables SASL implementation for Enterprise builds by updating the CMake configuration and wrapping stub functions in transSasl.c with preprocessor guards. A critical feedback point identifies that a newly added NULL check for pConn is placed within a non-Enterprise block, meaning it will be bypassed in Enterprise builds. It is recommended to move this check to a common wrapper function to ensure consistent protection against null pointer dereferences across all build configurations.
| } | ||
|
|
||
| int8_t saslConnShoudDoAuthImpl(SSaslConn * pConn) { | ||
| if (pConn == NULL) return 1; |
There was a problem hiding this comment.
The NULL pointer check for pConn is added within the stub implementation of saslConnShoudDoAuthImpl, which is wrapped in a #if !defined(TD_ENTERPRISE) block. However, the changes in CMakeLists.txt indicate that this build is intended to support Enterprise features where TD_ENTERPRISE is defined. In Enterprise builds, this stub is skipped, and the check will not be present. To effectively prevent potential crashes (e.g., in transSvr.c at line 1752), this NULL check should be moved to the wrapper function saslAuthIsInited at line 74, which is used by both Enterprise and non-Enterprise configurations.
cd61bd9 to
0a63e33
Compare
There was a problem hiding this comment.
Pull request overview
This PR adjusts the transport library’s SASL compilation/selection logic, aiming to (1) enable the enterprise SASL implementation in the build and (2) avoid problematic SASL state checks when the SASL connection pointer is NULL.
Changes:
- Enable building the enterprise
transSaslImpl.cimplementation in transport’s CMake. - Wrap non-enterprise SASL stub implementations under a preprocessor guard and add a NULL handling path in the stub
saslConnShoudDoAuthImpl. - Minor whitespace cleanup in
transSvr.c.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| source/libs/transport/src/transSvr.c | Minor whitespace-only cleanup. |
| source/libs/transport/src/transSasl.c | Adds conditional compilation for stub SASL impls and a NULL check in the stub auth-state function. |
| source/libs/transport/CMakeLists.txt | Enables building enterprise SASL implementation source file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| int8_t saslConnShoudDoAuthImpl(SSaslConn * pConn) { | ||
| if (pConn == NULL) return 1; | ||
| return 0; |
There was a problem hiding this comment.
The new NULL handling was added inside the non-enterprise stub implementation. When TD_ENTERPRISE is defined, saslAuthIsInited(NULL) will still dispatch to the enterprise saslConnShoudDoAuthImpl implementation via the wrapper without any NULL guard. Since several call sites pass conn->saslConn without checking for NULL, the NULL check should be enforced in a common location (e.g., in saslAuthIsInited) or guaranteed in the enterprise impl as well; otherwise the reported null-pointer issue may persist for enterprise builds.
| IF(TD_ENTERPRISE) | ||
| LIST(APPEND TRANSPORT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/trans/src/transTLSImpl.c) | ||
| #LIST(APPEND TRANSPORT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/trans/src/transSaslImpl.c) | ||
| LIST(APPEND TRANSPORT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/trans/src/transSaslImpl.c) |
There was a problem hiding this comment.
transSaslImpl.c is now always added when TD_ENTERPRISE is enabled, but libsasl2 is only pulled in on Linux later in this CMake file. If enterprise builds are supported on non-Linux platforms (the top-level options.cmake suggests enterprise Windows builds exist), this unconditional source inclusion can break compilation/linking. Consider appending transSaslImpl.c only when TD_ENTERPRISE && TD_LINUX (or otherwise ensure transSaslImpl.c is fully guarded for non-Linux builds).
| LIST(APPEND TRANSPORT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/trans/src/transSaslImpl.c) | |
| IF(TD_LINUX) | |
| LIST(APPEND TRANSPORT_SRC ${TD_ENTERPRISE_DIR}/src/plugins/trans/src/transSaslImpl.c) | |
| ENDIF() |
| saslBufferClearImpl(buf); | ||
| } | ||
|
|
||
| #if !defined(TD_ENTERPRISE) |
There was a problem hiding this comment.
The stub implementations are now compiled only when TD_ENTERPRISE is not defined. However, the transport SASL header and build logic indicate SASL is only available on enterprise Linux (e.g., header includes <sasl/sasl.h> only for TD_ENTERPRISE && LINUX, and libsasl2 is only linked on Linux). For enterprise builds on non-Linux (e.g., Windows), this guard would remove the stubs and likely leave these symbols undefined. Consider changing the guard to compile stubs whenever !(defined(TD_ENTERPRISE) && defined(LINUX)) so non-Linux enterprise builds still have a working fallback.
| #if !defined(TD_ENTERPRISE) | |
| #if !(defined(TD_ENTERPRISE) && defined(LINUX)) |
0a63e33 to
14c5dde
Compare
Description
Issue(s)
Checklist
Please check the items in the checklist if applicable.