Skip to content

Reject negative JRuby key lengths consistently - #44

Open
OskarEichler wants to merge 1 commit into
net-ssh:mainfrom
OskarEichler:codex/reject-negative-jruby-key-length
Open

Reject negative JRuby key lengths consistently#44
OskarEichler wants to merge 1 commit into
net-ssh:mainfrom
OskarEichler:codex/reject-negative-jruby-key-length

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary:

  • reject every key length below one in the JRuby implementation
  • extend the shared invalid-argument coverage to negative lengths

Why:
The Java implementation checks only keylen == 0. A negative key length therefore reaches new byte[keylen] and raises NegativeArraySizeException, while the MRI boundary rejects out-of-range lengths. Treating keylen < 1 as invalid keeps the Java implementation inside the method contract and returns nil consistently.

Verification:

  • Java model reproduces NegativeArraySizeException before the change and nil afterward
  • shared current suite remains green on MRI: 8 runs, 31 assertions
  • existing jBCrypt vectors, including the 64-byte multi-block case, pass

Compatibility:
Positive key lengths are unchanged. Negative low-level inputs now return nil instead of leaking a Java allocation exception.

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