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.
-
Validate size and offset fields against the actual buffer length before reading or writing.
Seen in 6 reports
-
Validate size, length and structure fields in the file before using them.
Seen in 6 reports
-
Validate that enough bytes remain in the packet buffer before reading a field.
Seen in 6 reports
-
Validate user-supplied pointers and sizes before use, including overflow checks on size arithmetic.
Seen in 6 reports
-
Add bounds checks before reading or writing parsed data.
Seen in 5 reports
-
Check data length before copying into heap or stack buffers and reject oversized input.
Seen in 5 reports
-
Check for overflow and underflow when computing buffer sizes and indices, and use unsigned or checked arithmetic.
Seen in 5 reports
-
Check for overflow before adding or multiplying size values, and initialise memory before use.
Seen in 5 reports
-
Check for overflow before using untrusted sizes in allocation or loop arithmetic.
Seen in 5 reports
-
Check size and offset values from the file against the actual allocated buffer before reading or writing.
Seen in 5 reports
-
Check that a length or offset read from a file stays within the allocated buffer before reading.
Seen in 5 reports
-
Check that an annotation object still exists before operating on it.
Seen in 5 reports
-
Check that an object still exists before using it, and do not free a structure while another component still holds a pointer to it.
Seen in 5 reports
-
Check that an object still exists before using or freeing it, and guard against double free.
Seen in 5 reports
-
Check that the size used for allocation matches the size used for writing.
Seen in 5 reports
-
Clear pointers after freeing and check object validity before every use.
Seen in 5 reports
-
Confirm an object still exists before using it, and keep references alive across callbacks.
Seen in 5 reports
-
Correct how the subsystem handles objects in memory to remove the integer overflow.
Seen in 5 reports
-
Correct type handling and buffer sizing in Ruby extension bindings.
Seen in 5 reports
-
Do not dereference user-supplied values as pointers without validating that they refer to valid memory.
Seen in 5 reports
-
Fix object lifetime handling so freed objects are not reused, and validate pointers received from untrusted callers.
Seen in 5 reports
-
Handle integer overflow, underflow and wraparound safely.
Seen in 5 reports
-
Hold a weak reference or otherwise ensure object lifetime before using a captured pointer in an asynchronous completion handler.
Seen in 5 reports
-
Hold strong references or cancel pending callbacks when the owning object is torn down.
Seen in 5 reports
-
Hold strong references or use weak pointers across callbacks that can destroy the object.
Seen in 5 reports
-
Initialise memory and pointers before use.
Seen in 5 reports
-
Initialise pointers before dereferencing them.
Seen in 5 reports
-
Security update corrects how the kernel handles objects in memory.
Seen in 5 reports
-
Use overflow-safe arithmetic when computing allocation sizes from file or client data.
Seen in 5 reports
-
Validate client-supplied indices and lengths before using them to access arrays or copy into buffers.
Seen in 5 reports
-
Validate input types before buffer allocation and zero-fill allocated buffers.
Seen in 5 reports
-
Validate length and size fields from files against the destination buffer before copying.
Seen in 5 reports
-
Validate length and size fields from the file against the destination buffer capacity before copying, and check indices against table bounds.
Seen in 5 reports
-
Validate length, offset and type fields from the file before using them to read or write memory.
Seen in 5 reports
-
Validate length, size and offset fields from files and network packets against the destination buffer before copying, and check array indexes against bounds.
Seen in 5 reports
-
Validate pointers and object types before dereferencing or casting them.
Seen in 5 reports
-
Validate pointers before dereferencing or releasing them.
Seen in 5 reports
-
Validate size conversions between integer widths so a large size cannot become negative or underflow.
Seen in 5 reports
-
Validate that pointers come from a trusted source before dereferencing them.
Seen in 5 reports
-
Validate the size and bounds of user input in IOCTL handlers before any memory operation.
Seen in 5 reports
-
Validate the size of user-supplied data before using it to allocate a buffer.
Seen in 5 reports
-
Vendor fixed these with improved memory management and improved input validation.
Seen in 5 reports
-
Add bounds checks before writing to heap and stack buffers and validate numeric fields before size calculations.
Seen in 4 reports
-
Add proper bounds checks and input validation before memory access or allocation.
Seen in 4 reports
-
Bound the length of HTTP header values before copying them into fixed buffers.
Seen in 4 reports
-
Bounds-check indices taken from user data before using them to access arrays.
Seen in 4 reports
-
Check allocation size calculations for integer overflow before allocating and copying.
Seen in 4 reports
-
Check arithmetic on size and count values before use to prevent wraparound.
Seen in 4 reports
-
Check arithmetic on sizes and lengths for overflow and wraparound before using the result.
Seen in 4 reports
-
Check arithmetic on sizes and types so underflow, overflow and bad conversions cannot corrupt memory.
Seen in 4 reports