Skip to content

fix: in unity_malloc (unity_memory in unity_memory.c#832

Open
orbisai0security wants to merge 1 commit into
ThrowTheSwitch:masterfrom
orbisai0security:fix-heap-overflow-unity-memory
Open

fix: in unity_malloc (unity_memory in unity_memory.c#832
orbisai0security wants to merge 1 commit into
ThrowTheSwitch:masterfrom
orbisai0security:fix-heap-overflow-unity-memory

Conversation

@orbisai0security
Copy link
Copy Markdown

Summary

Fix critical severity security issue in extras/memory/src/unity_memory.c.

Vulnerability

Field Value
ID V-001
Severity CRITICAL
Scanner multi_agent_ai
Rule V-001
File extras/memory/src/unity_memory.c:96
CWE CWE-120

Description: In unity_malloc (unity_memory.c:96-103), UNITY_MALLOC allocates total_size bytes for a Guard structure plus user data. The memcpy at line 103 writes a guard pattern to &mem[size] without verifying that size + sizeof(end) does not exceed total_size. If total_size overflows during calculation or size is otherwise incorrect, &mem[size] points beyond the allocated heap region, causing a heap buffer overflow. In unity_realloc (line 200), memcpy(newMem, oldMem, guard->size) copies guard->size bytes into the new allocation without verifying guard->size does not exceed the new allocation's capacity, enabling a second heap overflow path.

Changes

  • extras/memory/src/unity_memory.c

Verification

  • Build passes
  • Scanner re-scan confirms fix
  • LLM code review passed

Automated security fix by OrbisAI Security

Automated security fix generated by Orbis Security AI

Signed-off-by: orbisai0security <mediratta01.pally@gmail.com>
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