In-depth lesson · Memory corruption
Typical fixes
Every point the Memory corruption reports back under this heading, best-backed first, each with the reports it is seen in.
-
Reject negative or oversized size fields and check arithmetic for overflow before using the result as a length.
Seen in 3 reports
-
Replace unbounded sprintf and strcat into fixed stack buffers with length-checked copies.
Seen in 3 reports
-
Reset global state and clean up partially initialised structures when a request aborts with an out-of-memory error.
Seen in 3 reports
-
Security update corrects how the kernel-mode driver handles objects in memory.
Seen in 3 reports
-
Security update corrects how the service handles objects in memory.
Seen in 3 reports
-
Security updates corrected how the affected components handle objects in memory.
Seen in 3 reports
-
Size buffers from the actual render quantum at runtime rather than a compile-time constant, and keep the bounds check in release builds.
Seen in 3 reports
-
Stop timers and clear handles during pre-finalisation, and root wrappers in the persistent map.
Seen in 3 reports
-
The length check should reject names and paths of exactly the maximum length, using greater-than-or-equal rather than greater-than.
Seen in 3 reports
-
The update corrected how the CLFS driver handles objects in memory.
Seen in 3 reports
-
Use bounded formatting instead of an unbounded formatted print when building error messages into fixed-size buffers.
Seen in 3 reports
-
Use checked 64-bit arithmetic for buffer size calculations and account for primitive restart expansion.
Seen in 3 reports
-
Use weak pointers and existence checks before dereferencing objects that callbacks or other threads may free.
Seen in 3 reports
-
Validate embedded font data before processing it in the font driver.
Seen in 3 reports
-
Validate image dimensions and component counts against the allocated buffer size before decoding.
Seen in 3 reports
-
Validate indices and sizes in IPC deserialisers against the accompanying lists and buffers before use.
Seen in 3 reports
-
Validate length and offset fields from the file before using them to read from or write to a buffer.
Seen in 3 reports
-
Validate numeric values used in size calculations before allocation to prevent overflow and underflow.
Seen in 3 reports
-
Validate pointer types and size arithmetic in kernel drivers.
Seen in 3 reports
-
Validate pointers and references supplied by low-privileged callers before dereferencing or releasing them.
Seen in 3 reports
-
Validate pointers before dereferencing them.
Seen in 3 reports
-
Validate request lengths and sizes before copying, and hold references to objects until packet handling completes.
Seen in 3 reports
-
Validate that a file-supplied value points to valid memory before dereferencing it.
Seen in 3 reports
-
Validate that a pointer taken from untrusted input points to trusted memory before dereferencing it, and check for null before use.
Seen in 3 reports
-
Validate the length of DNS name data and error codes before copying into fixed-size buffers.
Seen in 3 reports
-
Validate the length of user-supplied buffers before copying data into them.
Seen in 3 reports
-
Validate the length of user-supplied data before writing it into a fixed-size buffer.
Seen in 3 reports
-
Validate the type of parsed data before casting or using it.
Seen in 3 reports
-
Validate the type of structures read from project files before using them.
Seen in 3 reports
-
Validate user-supplied lengths and counts before copying or allocating, and check object existence before use.
Seen in 3 reports
-
Validate user-supplied values before arithmetic and check for overflow and underflow before memory writes.
Seen in 3 reports
-
Validate user-supplied values before dereferencing them as pointers.
Seen in 3 reports
-
Wait for pending GPU work before releasing resources, and do not skip synchronisation on error paths.
Seen in 3 reports
-
Add bounds validation when parsing annotation objects.
-
Apply the same script-length limit on the eager Baseline path and fail rather than truncate when offsets exceed the bitfield width.
Seen in 2 reports
-
Bound formatted output and Content-Length handling in the MXIT protocol.
-
Bound the attribute loop by the response buffer size rather than the requested count.
-
Cancel delayed tasks and weak-bind callbacks so they cannot run after the owning object is destroyed.
Seen in 2 reports
-
Carry the argument-mode flag into the sizing pass so both passes agree on escaping.
Seen in 2 reports
-
Change how RTF content and document objects are parsed and validated.
Seen in 2 reports
-
Check certificate and response sizes before copying into fixed heap buffers and guard against use after free during connection handling.
-
Check for integer overflow and confirm the new size is large enough before doubling a buffer.
Seen in 2 reports
-
Check length and count values for underflow and wraparound before using them.
-
Check stride and offset values against an upper bound and the actual allocation size.
Seen in 2 reports
-
Check that a Collab object still exists before operating on it.
-
Check that indices read from the file are within the valid range before using them.
-
Check the length before copying file-supplied data into a fixed-length heap buffer.
-
Check the result of map insertions and only store pointers to objects that were successfully inserted.
Seen in 2 reports
-
Check the return value of reads and recursive calls before using or freeing the result.
-
Clamp parser output to the specification's maximum values before passing it to hardware drivers.