Skip to content

LTE-2939- Added code improvements to prevent SSL_write crash - #17

Open
annie-rashmitha wants to merge 10 commits into
rdkcentral:mainfrom
annie-rashmitha:main
Open

annie-rashmitha wants to merge 10 commits into
rdkcentral:mainfrom
annie-rashmitha:main

Conversation

@annie-rashmitha

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 09:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Successful debug-mode sends are incorrectly logged and returned as failures.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds synchronized SSL writes and connection teardown to prevent SSL_write crashes.

Changes:

  • Introduces a mutex-protected SSL write helper.
  • Migrates message and file-transfer writes to the helper.
  • Synchronizes SSL shutdown and resource cleanup.
File Description
Idm_TCP_apis.h Declares the safe SSL write API.
Idm_TCP_apis.c Implements synchronized writes and teardown.
Idm_msg_process.c Uses connection-aware safe writes for file-transfer responses.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread source/InterDeviceManager/Idm_TCP_apis.c Outdated
Copilot AI balanced review requested due to automatic review settings October 1, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Blocking TLS shutdown can stall all device communication, and the write API narrows lengths without validation.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity size_t payload length can overflow SSL_write's int parameter

source/​InterDeviceManager/​Idm_TCP_apis.c:88

payload_len is exposed as size_t but is unconditionally narrowed to the int length accepted by SSL_write. Values above INT_MAX are converted to an invalid/truncated length, so this API cannot safely honor its declared input range. Reject lengths above INT_MAX (and include <limits.h>) or change the API to use a bounded integer type.

pthread_mutex_lock(&ssl_io_mutex);

if (conn_info->enc.ssl != NULL) {
SSL_shutdown(conn_info->enc.ssl);
Comment thread source/InterDeviceManager/Idm_TCP_apis.c Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 09:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Global locking can stall all peers, while multi-write file transactions can still be interleaved and corrupted.

Review effort: Balanced
Findings: 2 High severity

Open (2)
Resolved since last review (1)

return FT_ERROR;
}
if ((bytes = SSL_write(conn_info->enc.ssl, Data, sizeof(payload_t))) > 0)
if ((bytes = idm_ssl_write_safe(conn_info, Data, sizeof(payload_t))) > 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants