Skip to content

add tests for invalid keylen guard (issue #31/#33)#37

Merged
mfazekas merged 2 commits into
mainfrom
test-invalid-keylen-guard
Jun 13, 2026
Merged

add tests for invalid keylen guard (issue #31/#33)#37
mfazekas merged 2 commits into
mainfrom
test-invalid-keylen-guard

Conversation

@mfazekas

@mfazekas mfazekas commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Adds regression tests and a valgrind-based CI job for the memory leaks fixed in #34.

Tests (test_invalid_keylen_returns_nil, test_invalid_keylen_does_not_leak_memory): verify that keylen=0, keylen>1024, and rounds=0 return nil, and that repeated calls with an out-of-range keylen don't leak.

Memcheck CI job: runs the test suite under valgrind via ruby_memcheck on Ubuntu. On unfixed code, each call to __bc_crypt_pbkdf("pass", "salt", 2000, 1) leaks 2000 bytes (xmalloc before the guard, no xfree on the error path); the 1000-iteration test produces ~2MB of reported leaks and fails the job. With #34's fix applied the guard fires before xmalloc and the job passes.

Gemfile.memcheck keeps ruby_memcheck out of the main bundle (it requires Ruby >= 3.0, the project supports 2.7).

@mfazekas mfazekas force-pushed the test-invalid-keylen-guard branch from dc1bc86 to deacadf Compare June 13, 2026 13:46
@mfazekas mfazekas merged commit 700e9c9 into main Jun 13, 2026
13 checks passed
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