Skip to content

Fix ctl_path length boundary - #63

Open
salva wants to merge 2 commits into
masterfrom
fix/ctl-path-length-boundary
Open

Fix ctl_path length boundary#63
salva wants to merge 2 commits into
masterfrom
fix/ctl-path-length-boundary

Conversation

@salva

@salva salva commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

Reject control socket paths that fill sun_path without room for the required terminating NUL byte.

Changes

  • Treat sizeof(sun_path) - 1 as the maximum usable path length.
  • Update the error message to report the usable maximum.
  • Add a boundary regression test for accepted and rejected lengths.
  • Add the new test to MANIFEST.

Fixes #44.

Testing

  • perl -Ilib -c lib/Net/OpenSSH.pm
  • perl -Ilib t/ctl-path.t

Copilot AI review requested due to automatic review settings June 4, 2026 11:55

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.

Pull request overview

This PR fixes an off-by-one boundary in ctl_path validation so Unix-domain control socket paths always leave room for the required terminating NUL in sun_path, improving early validation and error reporting.

Changes:

  • Reject ctl_path values whose length is >= sizeof(sun_path) (i.e., enforce a usable limit of sizeof(sun_path) - 1).
  • Update the validation error message to report the usable maximum length.
  • Add a regression test covering the boundary (limit accepted, limit + 1 rejected) and include it in MANIFEST.

Reviewed changes

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

File Description
lib/Net/OpenSSH.pm Tightens ctl_path length validation to enforce sizeof(sun_path) - 1 usable limit and updates the reported maximum.
t/ctl-path.t Adds a boundary regression test for accepted/rejected ctl_path lengths.
MANIFEST Includes the new t/ctl-path.t test file in the distribution manifest.

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

Comment thread t/ctl-path.t Outdated
Comment on lines +28 to +29
my $ssh = Net::OpenSSH->new(host => 'localhost', ctl_path => $good,
connect => 0, strict_mode => 0);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in commit 404b1e3 by passing an explicit ssh_version in this constructor call. Re-ran perl -Ilib t/ctl-path.t.

Comment thread t/ctl-path.t Outdated
Comment on lines +33 to +34
$ssh = Net::OpenSSH->new(host => 'localhost', ctl_path => $bad,
connect => 0, strict_mode => 0);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in commit 404b1e3 by passing an explicit ssh_version in this negative-path constructor call too. Re-ran perl -Ilib t/ctl-path.t.

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.

Control socket path length check may be off by one

2 participants