Skip to content

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.

Back to the lesson 851 to 900 of 976
  1. Track ownership of the trial and best pointers so a failed iteration does not free the same memory twice.

    Seen in 1 report
  2. Track which pages belong to which mapping when a queue is rebound so closing an old mapping does not free pages in use.

    Seen in 1 report
  3. Treat a failed AMSI scan as suspicious rather than clean, and protect the AMSI context from tampering.

    Seen in 1 report
  4. Treat incomplete input as invalid and stop processing after a block-type switch error.

    Seen in 1 report
  5. Treat negative width and height values as invalid before the size sanity check.

    Seen in 1 report
  6. Update local pointers after a realloc moves the buffer.

    Seen in 1 report
  7. Update the remaining length and invalidate the pointer when a buffer is freed during unmarshalling.

    Seen in 1 report
  8. Update the stale pointer after reallocating the buffer.

    Seen in 1 report
  9. Upgrade nginx to a version that fixes the chunked transfer-encoding stack buffer overflow.

    Seen in 1 report
  10. Use 64-bit arithmetic for the chroma plane size calculation.

    Seen in 1 report
  11. Use a flexible array member instead of a pointer array so the allocation fits the copied string.

    Seen in 1 report
  12. Use a greater-or-equal comparison when checking an index against an array length.

    Seen in 1 report
  13. Use a reference count width that cannot overflow, or check for saturation before incrementing.

    Seen in 1 report
  14. Use a safe allowlist for classes that a JSON deserializer may instantiate.

    Seen in 1 report
  15. Use a wider integer or check for overflow when expanding the association group table.

    Seen in 1 report
  16. Use a zero base array layer for 3D texture copies and map the z offset correctly.

    Seen in 1 report
  17. Use bounded string copies and check input length against the fixed buffer in argument handling.

    Seen in 1 report
  18. Use bounded string copying and verify the host string length against the buffer size.

    Seen in 1 report
  19. Use checked arithmetic for the entry buffer size calculation.

    Seen in 1 report
  20. Use checked arithmetic when accumulating glyph counts.

    Seen in 1 report
  21. Use one less than the buffer size in the bounds check.

    Seen in 1 report
  22. Use overflow-checked arithmetic when summing unpack stream counts.

    Seen in 1 report
  23. Use overflow-safe arithmetic in the precision bounds check.

    Seen in 1 report
  24. Use overflow-safe bounds checks that cannot wrap around.

    Seen in 1 report
  25. Use the actual argument count in callbacks rather than fixed stack loads and cleanup.

    Seen in 1 report
  26. Use the actual source length rather than the destination buffer size in copy calls.

    Seen in 1 report
  27. Use the actual truncated length returned by the bounded string formatting call when sending the response.

    Seen in 1 report
  28. Use the correct comparison so a value equal to the buffer size is rejected.

    Seen in 1 report
  29. Use the destination buffer size rather than the input length when copying the title.

    Seen in 1 report
  30. Use the length prefix of the wide string instead of scanning for a null terminator.

    Seen in 1 report
  31. Use the request object for metrics before resolving the promise so user code cannot free it in between.

    Seen in 1 report
  32. Use the return value of readlink to set the real length instead of trusting the size from lstat.

    Seen in 1 report
  33. Use the same length variable for allocation and for the read.

    Seen in 1 report
  34. Use unsigned branch instructions when comparing the size parameter in memcpy.

    Seen in 1 report
  35. Use user-safe copy routines when writing to user-supplied addresses.

    Seen in 1 report
  36. Use weak references for the web state list in completion blocks and check for nil before dereferencing.

    Seen in 1 report
  37. Validate an annotation pointer after the object has been freed.

    Seen in 1 report
  38. Validate and clamp specification-defined field widths at IPC deserialisation rather than trusting the sender.

    Seen in 1 report
  39. Validate array indices from file headers against the parsed table range.

    Seen in 1 report
  40. Validate array indices taken from file data.

    Seen in 1 report
  41. Validate B-record fields against the Type A grid dimensions before the write loop runs.

    Seen in 1 report
  42. Validate both x and y coordinates against the image dimensions before writing pixels.

    Seen in 1 report
  43. Validate bounding box coordinates and avoid truncating floating-point values to signed integers for loop counters.

    Seen in 1 report
  44. Validate client input length and count values before use in request parsing.

    Seen in 1 report
  45. Validate image dimensions before allocating memory for conversion.

    Seen in 1 report
  46. Validate input before use in the affected component.

    Seen in 1 report
  47. Validate input lengths and pointers when parsing authentication tokens.

    Seen in 1 report
  48. Validate neighbour vertex IDs against the declared vertex count before storing and using them as point indices.

    Seen in 1 report
  49. Validate node and element indices against the allocated bounds before indexing.

    Seen in 1 report