Skip to content

Honor nil and negative limits as unlimited in gets - #171

Open
OskarEichler wants to merge 1 commit into
net-ssh:masterfrom
OskarEichler:codex/gets-unlimited-length
Open

Honor nil and negative limits as unlimited in gets#171
OskarEichler wants to merge 1 commit into
net-ssh:masterfrom
OskarEichler:codex/gets-unlimited-length

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Normalize nil and negative limits to the existing unlimited value before slicing or comparing the buffer.

Reproduction and evidence

For a file containing "a\nb\n", gets("\n", -1) returns incorrect data/position on the baseline and gets("\n", nil) fails. Both now return "a\n" at position 2, matching StringIO. Positive/zero limits retain their behavior.

Verification

  • Baseline and this isolated patch: 433 existing tests / 1,201 assertions, no failures/errors/skips, Ruby 4.0.6 via rbenv, net-ssh 7.3.3, Minitest 5.27.0 and Mocha 2.1.0.
  • 12,000 external assertions compare repeated reads and positions with StringIO across deterministic data, separator choices, small response fragments and negative/nil limits.
  • Combined candidate also passes the prior 10,384 model assertions, 12,200 additional mixed line/glob assertions, 27 bounded local OpenSSH pipe checks and the existing suite with frozen literals enabled and disabled. Combined checks include the separately proposed Write at the logical position after buffered reads #163Preserve numeric create and truncate flags in v5 open requests #170 and attributed portions of Handle frozen strings #157/ensure ruby 4 compatibility and address some security concerns #162; these are not additional changes in this PR.
  • All 37 package paths and dependency metadata preserved. All 26 runtime files compile on Ruby 4.0.6 and parse as Ruby 2.5. Comparative Lint retains the same 33 baseline findings; no full-green claim.

Breaking changes and limitations

Intentional correction: nil/negative limits are now unlimited; callers depending on negative slicing must use explicit positive limits. No signature change or expansion of float/string coercion.

No repository tests added or modified under the task's no-new-tests constraint; focused scripts ran outside the repository. An external verification Gemfile supplies test tools/RDoc without changing upstream tooling. Older Ruby/JRuby/Windows and upstream CI have not been verified. No production/SSH connections, unrelated upgrades, release changes or signature-equivalence claim.

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.

1 participant