-
Notifications
You must be signed in to change notification settings - Fork 3k
ssh: fix handle id generation #10003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
u3s
commented
Jun 30, 2025
- generate unique file handles
CT Test Results 2 files 29 suites 18m 47s ⏱️ Results for commit 981a866. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
34b4aac to
ba19a35
Compare
ba19a35 to
6458011
Compare
There was a problem hiding this 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 enhances the SFTP server’s handle ID generation to ensure unique IDs and reuse freed gaps, and updates the test suite to verify this behavior.
- Introduce
new_handle_idandfind_gapto replace the old recursivenew_handle, finding the lowest unused handle ID and reusing gaps. - Update
ssh_sftpd_SUITE.erlto generate multiple file handles, assert uniqueness, and test gap reuse. - Add
binary_to_integer/1for parsing handles and includeassert.hrl.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/ssh/src/ssh_sftpd.erl | Replaced new_handle/2 with new_handle_id + find_gap, and updated handle parsing to binary_to_integer/1. |
| lib/ssh/test/ssh_sftpd_SUITE.erl | Added test logic to write multiple files, collect handles, assert uniqueness, reuse gaps, and included assert.hrl. |
| lib/ssh/test/ssh_sftpd_SUITE_data/* | Added ED25519 public/private key test fixtures. |
Comments suppressed due to low confidence (3)
lib/ssh/test/ssh_sftpd_SUITE.erl:734
- Consider adding a test case for the initial empty handle list (no existing handles) to verify that the first generated handle ID is
0.
%% repeat procedure to make sure uniq file handles are generated
lib/ssh/test/ssh_sftpd_SUITE.erl:63
- The
assert.hrlinclude appears unused since?assertEqualcomes fromct.hrl. Consider removing this include to reduce unnecessary dependencies.
-include_lib("stdlib/include/assert.hrl").
lib/ssh/src/ssh_sftpd.erl:451
binary_to_integer/1was introduced in OTP 25. If this library needs to support older OTP releases, consider adding a fallback (e.g.,list_to_integer(binary_to_list(BinHandle))).
case (catch binary_to_integer(BinHandle)) of
6458011 to
563241b
Compare
563241b to
981a866
Compare