Skip to content

Posix fixes#322

Merged
bigbrett merged 5 commits intomainfrom
POSIX-fixes
Mar 24, 2026
Merged

Posix fixes#322
bigbrett merged 5 commits intomainfrom
POSIX-fixes

Conversation

@jackctj117
Copy link
Copy Markdown
Contributor

This pull request focuses on improving security, safety, and resource management in the POSIX transport code, particularly for TLS and shared memory transports. The main areas of change include stricter file permissions, enhanced compile-time safety checks, and more robust handling of file descriptors to prevent resource leaks and errors.

Security and Safety Improvements:

  • Changed shared memory creation mode in posix_transport_shm.c from 0666 (world-writable) to 0660 (group-writable only), reducing unnecessary permissions.
  • Added a compile-time check in posix_transport_tls.c to ensure that PTTLS_PACKET_MAX_SIZE and WH_COMM_MTU are always equal, preventing potential buffer overflows during TLS operations.

Resource Management and Error Handling:

  • Improved error handling in posixTransportTls_SendRequest, posixTransportTls_RecvRequest, and related functions by ensuring file descriptors are properly closed and context fields are reset to 0 on failure, preventing resource leaks and dangling references. [1] [2] [3] [4]
  • Enhanced cleanup logic in posixTransportTls_InitListen to ensure that both the SSL context and the underlying TCP context are cleaned up if initialization fails, avoiding partial resource leaks. [1] [2]

Copilot AI review requested due to automatic review settings March 23, 2026 17:18
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

Improves POSIX transport security and robustness by tightening shared-memory permissions, adding a compile-time MTU/packet-size invariant, and strengthening TLS socket/SSL cleanup on failure paths.

Changes:

  • Reduced shared memory creation permissions from world-writable to group-writable (0666 → 0660).
  • Added a compile-time assertion to ensure TLS packet size matches the communication MTU.
  • Ensured TLS listen/init and recv error paths close file descriptors and reset context state to avoid leaks/dangling fds.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
port/posix/posix_transport_tls.c Adds compile-time size check; improves TLS listen/init and recv cleanup to close fds and reset fields on failures.
port/posix/posix_transport_shm.c Tightens shared memory creation mode to reduce unnecessary permissions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bigbrett bigbrett merged commit 7eefbcd into main Mar 24, 2026
55 checks passed
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.

4 participants