You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MISRA-CERT-01] Integer overflow not checked in generated C (MISRA Rule 12.1, CERT INT32-C) #263
CERTCERT C Secure Coding Standard complianceMISRAMISRA C:2024 compliance for safety-critical generated codecompilerenhancementNew feature or requestsecurity
The C generator emits raw arithmetic for +, -, * on integer types with no overflow check. Signed integer overflow is undefined behavior in C (C11 6.5p5).
Reproduction:
function main() -> i32 {
let y: i32 = 2147483647 + 1
return y
}
Generated C:
int32_ty= (2147483647+1); // signed overflow, UB
src/flow/c_generator.py line 3137: return f"({left_expr} {c_operator} {right_expr})" emits the raw operation.
Standards
MISRA C:2024 Rule 12.1 (Required): Signed integer overflow shall not occur.
CERT C INT32-C: Ensure that integer operations do not result in an overflow.
Fix
Add a --checked-arith flag (or --profile safety) that emits overflow-checked arithmetic using __builtin_sadd_overflow / __builtin_smul_overflow / __builtin_ssub_overflow (Clang/GCC builtins) or a portable fallback. Abort or call a configurable handler on overflow.
Audit ID: MISRA-CERT-01
Severity: Critical | Category: C generator - arithmetic safety
CERTCERT C Secure Coding Standard complianceMISRAMISRA C:2024 compliance for safety-critical generated codecompilerenhancementNew feature or requestsecurity
Activity
feat(safety): MISRA Phase 1 + if-expressions
feat(safety): safety manifest generator (--emit-manifest) (#290)
docs: update README to 0.10.0 with safety profiles and current stats (#…