Skip to content

Conversation

@ekse
Copy link
Owner

@ekse ekse commented Dec 2, 2025

🐕 Corgea issued a PR to fix a vulnerability found in lib/libwasm.c.

It is CWE-190: Integer Overflow or Wraparound that has a severity of 🔴 High.

🪄 Fix explanation

The fix prevents integer overflow when calculating memory allocation size by casting to "size_t" and validating that adding 1 doesn’t wrap around, ensuring safe allocation and mitigating overflow-related vulnerabilities.
- Cast "field_len" to "size_t" before adding 1 to avoid overflow in pointer-size arithmetic: "size_t alloc_size = (size_t) field_len + 1;".
- Verify no wraparound by checking "alloc_size <= field_len"; if true, jump to error handling to prevent unsafe allocation.
- Replace original allocation with "calloc(1, alloc_size)", ensuring correct memory size is requested.
- Add a null check for the allocation result, jumping to "parse_error" if allocation fails, improving robustness.

💡 Important Instructions

Ensure that parse_error handles cleanup correctly to prevent memory leaks or undefined behavior after this early exit.

See the issue and fix in Corgea.

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.

2 participants