Skip to content

channel: fix comment about handling of trailing zero byte#1781

Merged
willco007 merged 2 commits intolibssh2:masterfrom
LarsNordin-LNdata:channel.c-replace-wrong-comment-about-handling-of-trailing-zero-byte
Apr 6, 2026
Merged

channel: fix comment about handling of trailing zero byte#1781
willco007 merged 2 commits intolibssh2:masterfrom
LarsNordin-LNdata:channel.c-replace-wrong-comment-about-handling-of-trailing-zero-byte

Conversation

@LarsNordin-LNdata
Copy link
Copy Markdown
Contributor

No description provided.

@vszakats vszakats requested a review from Copilot January 15, 2026 18:43
@vszakats vszakats changed the title Channel.c replace wrong comment about handling of trailing zero byte channel: fix comment about handling of trailing zero byte Jan 15, 2026
Copy link
Copy Markdown

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 corrects a comment and removes unnecessary buffer allocation in the X11 forwarding cookie generation code. The original comment incorrectly described the handling of the trailing null byte from sprintf operations, and the buffer was over-allocated by 1 byte.

Changes:

  • Updated the comment to accurately describe that snprintf() writes the trailing null byte after the LIBSSH2_X11_RANDOM_COOKIE_LEN boundary in the output buffer s, which is safe because s has 4 extra bytes allocated for the screen_number
  • Removed the unnecessary + 1 from the buffer array size declaration since the local buffer is only used as input and doesn't need space for null termination

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

@willco007 willco007 merged commit 785cafa into libssh2:master Apr 6, 2026
101 of 102 checks passed
willco007 pushed a commit to willco007/libssh2 that referenced this pull request Apr 7, 2026
…1781)

Notes:
Removed the unnecessary + 1 from the buffer array size declaration since the local buffer is only used as input and doesn't need space for null termination.

Credit:
Lars Nordin
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