common: fix ubsan trigger in param test.
What changed, and why it matters
This commit fixes a test-only issue where a newer compiler's undefined-behavior sanitizer (UBSan) complained about a test that deliberately passes a NULL callback. The fix changes how the test constructs that NULL case so the sanitizer no longer flags it. It is not a security vulnerability in production code.
No security action required. Treat as a normal test-compatibility fix. If reviewing, confirm the new p_req_raw macro still exercises the same paramcheck_assert_failed code path.
Security signals we found
UndefinedBehaviorSanitizer warning in test code
NULL pointer arithmetic in macro expansion
Test-only workaround, no production code change
Evidence from the diff
The change is confined to common/test/run-param.c. The test bad_programmer() intentionally invokes p_req with a NULL param_cbx to verify that paramcheck_assert_failed is set. On newer Clang (Ubuntu 24.04 CI), UBSan reports ‘applying zero offset to null pointer’ inside the p_req macro. The patch introduces a p_req_raw macro that bypasses the macro’s normal pointer arithmetic, avoiding the sanitizer trigger while still testing the same assertion path. No runtime logic in the non-test param parsing code is changed.
Changed components
common/test/run-param.cInspect captured patch +10 / −1
diff --git a/common/test/run-param.c b/common/test/run-param.c
index 2f73a70e..3287eb27 100644
--- a/common/test/run-param.c
+++ b/common/test/run-param.c
@@ -376,9 +376,18 @@ static void bad_programmer(void)
p_req("repeat", param_millionths, &fpval), NULL);
assert(paramcheck_assert_failed);
+ /* UBSan gets upset with doing arith on NULL pointers, inside
+ * the p_req macro, so we do it raw here */
+#define p_req_raw(name, cbx, arg) \
+ name"", \
+ PARAM_REQUIRED, \
+ NULL, NULL, \
+ (param_cbx)(cbx), \
+ (arg)
+
paramcheck_assert_failed = false;
param(cmd, j->buffer, j->toks,
- p_req("u64", (param_cbx) NULL, NULL), NULL);
+ p_req_raw("u64", NULL, NULL), NULL);
assert(paramcheck_assert_failed);
/* Add required param after optional */
Why this scored 17/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.