Skip to content

fix(transport): fix SASL null pointer check and build config#35221

Open
yihaoDeng wants to merge 1 commit intomainfrom
fix/invalidTLS
Open

fix(transport): fix SASL null pointer check and build config#35221
yihaoDeng wants to merge 1 commit intomainfrom
fix/invalidTLS

Conversation

@yihaoDeng
Copy link
Copy Markdown
Contributor

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Copilot AI review requested due to automatic review settings April 23, 2026 08:54
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

@yihaoDeng yihaoDeng requested a review from a team as a code owner April 23, 2026 08:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.c implementation 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.

Comment on lines 136 to 138
int8_t saslConnShoudDoAuthImpl(SSaslConn * pConn) {
if (pConn == NULL) return 1;
return 0;
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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)
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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()

Copilot uses AI. Check for mistakes.
saslBufferClearImpl(buf);
}

#if !defined(TD_ENTERPRISE)
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
#if !defined(TD_ENTERPRISE)
#if !(defined(TD_ENTERPRISE) && defined(LINUX))

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants