Skip to content

Add test checking for NULL guards after OQS_MEM_malloc calls - #2633

Open
owaldron wants to merge 2 commits into
open-quantum-safe:mainfrom
owaldron:cleanup/check-null-after-malloc
Open

owaldron wants to merge 2 commits into
open-quantum-safe:mainfrom
owaldron:cleanup/check-null-after-malloc

Conversation

@owaldron

Copy link
Copy Markdown
Contributor

As mentioned in this comment, there are some outstanding malloc calls that were missing NULL checks. This PR used @claude to search for such instances and add the appropriate guard. It also adds test_malloc_null_check to verify that NULL guards immediately follow any OQS_MEM_* calls, along with the ability to suppress false positives.


  • Does this PR change the input/output behaviour of a cryptographic algorithm (i.e., does it change known answer test values)? (If so, a version bump will be required from x.y.z to x.(y+1).0.)
  • Does this PR change the list of algorithms available -- either adding, removing, or renaming? Does this PR otherwise change an API? (If so, PRs in fully supported downstream projects dependent on these, i.e., oqs-provider will also need to be ready for review and merge by the time this is merged. Also, make sure to update the list of algorithms in the continuous benchmarking files: .github/workflows/kem-bench.yml and sig-bench.yml)

Generative AI Disclosure: Claude Opus 5.5 was used to search the codebase for OQS_MEM_* calls that were missing NULL-guards. The test test_malloc_null_check was drafted by the same tool

owaldron and others added 2 commits October 15, 2026 15:03
Used Claude code to search for `OQS_MEM_malloc` and similar calls where
the output was not being checked for NULL. Added the checks where
appropriate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Owen Waldron <owen.waldron@uwaterloo.ca>
Created the `test_malloc_null_check` to check that `OQS_MEM_*` calls
are immediately followed by NULL checks, where appropriate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Owen Waldron <owen.waldron@uwaterloo.ca>
@owaldron owaldron mentioned this pull request Oct 15, 2026
1 of 2 tasks
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 80.312% (-4.2%) from 84.466% — owaldron:cleanup/check-null-after-malloc into open-quantum-safe:main

Comment thread tests/fuzz_test_sig_stfl_lms.c
Comment thread tests/fuzz_test_sig_stfl_xmss.c
Comment thread tests/kat_sig_stfl.c

# Ignore patterns to ignore false-positives in upstreams without the need to
# insert an `// IGNORE malloc-check`.
MALLOC_CHECK_IGNORED_DIRS = [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

whenever I see algorithm-specific code I wince -- particularly if it's excluding algorithms from scrutiny. Why is this so in this case?

This branch has not been deployed

No deployments
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.

4 participants