Skip to content

Validate rounds before native allocation - #43

Open
OskarEichler wants to merge 1 commit into
net-ssh:mainfrom
OskarEichler:codex/validate-native-rounds
Open

Validate rounds before native allocation#43
OskarEichler wants to merge 1 commit into
net-ssh:mainfrom
OskarEichler:codex/validate-native-rounds

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary:

  • convert rounds with NUM2UINT before allocating the output buffer
  • pass the validated unsigned value to bcrypt_pbkdf
  • cover values outside the native unsigned-int range

Why:
The extension currently converts rounds with NUM2ULONG and passes it to an unsigned int parameter. Values such as 2**32 + 1 silently truncate and behave like one round. Conversion also occurs after the native output allocation, complicating exceptional cleanup.

Verification:

  • existing current suite: 8 runs, 31 assertions, 0 failures
  • valid rounds retain identical output
  • 2**32 + 1 and negative values raise RangeError instead of truncating
  • native extension builds warning-free on Ruby 4.0.6

Compatibility:
Valid unsigned-int round counts are unchanged. Previously truncated out-of-range inputs are rejected explicitly.

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