Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces strlen() calls on string literals with compile-time sizeof("literal") - 1 in packet and SFTP code paths, keeping literal-length calculations constant-folded and avoiding runtime work.
Changes:
- Update SFTP subsystem startup to pass a compile-time length for
"sftp". - Replace multiple literal
strlen()usages in packet parsing and channel setup withsizeof(...)-1. - Update request-type comparisons (
exit-status,exit-signal) to use compile-time literal lengths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/sftp.c | Uses sizeof("sftp") - 1 for the subsystem name length when requesting SFTP. |
| src/packet.c | Converts literal-length computations in packet/channel parsing to sizeof(...)-1 and updates request string comparisons accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
Another "second look" comment: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reverts an earlier change doing the opposite.
sizeof()determineslength at build-time, while
strlen()does the same at runtime. In caseof literals the results are identical, but the build-time option does it
with zero runtime overhead.
Also:
Follow-up to bc4e619 Agent forwarding implementation #752
Follow-up to 88c5fd9 #2400
Follow-up to af1b501 #2224
Follow-up to 88a960a #1179