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 251 to 300 of 976
  1. Validate lengths and sizes against the target type range before conversion, and check allocation results before use.

    Seen in 4 reports
  2. Validate lengths before reading so parsers cannot read past the end of a buffer.

    Seen in 4 reports
  3. Validate object lifetime before use, check lengths and bounds before copying, and bound size calculations to prevent overflow.

    Seen in 4 reports
  4. Validate pointers received from callers or network responses before dereferencing them.

    Seen in 4 reports
  5. Validate pointers received from remote peers or attacker input before dereferencing them.

    Seen in 4 reports
  6. Validate size and count values and use safe arithmetic before allocating buffers.

    Seen in 4 reports
  7. Validate size and offset arithmetic so integer overflow or underflow cannot wrap into unsafe values.

    Seen in 4 reports
  8. Validate size and structure fields from files against the allocated buffer before reading or writing.

    Seen in 4 reports
  9. Validate that a caller-supplied value refers to legitimate memory before using it as a pointer.

    Seen in 4 reports
  10. Validate the minimum and maximum size of every field taken from a packet before casting or copying it.

    Seen in 4 reports
  11. Validate the size and length of user-supplied data before writing or copying it into buffers.

    Seen in 4 reports
  12. Validate the size and structure of embedded font data against the destination buffer before reading or writing.

    Seen in 4 reports
  13. Validate the type of array elements before processing them.

    Seen in 4 reports
  14. Validate user-supplied lengths and check for overflow before allocating buffers.

    Seen in 4 reports
  15. Validate user-supplied lengths before size calculations and use checked arithmetic to prevent overflow and underflow.

    Seen in 4 reports
  16. Add bounds checks before reading or writing user-supplied lengths and dimensions, as the platform advisories state for the audio, image and HID fixes.

    Seen in 3 reports
  17. Add bounds checks on input lengths and manage object lifetimes so freed objects cannot be reused.

    Seen in 3 reports
  18. Add improved checks on the type of user-supplied data before use.

    Seen in 3 reports
  19. Cancel pending callbacks and re-check object liveness after nested event loops and asynchronous operations.

    Seen in 3 reports
  20. Check a length variable for zero before decrementing it.

    Seen in 3 reports
  21. Check every file-controlled size and length against the remaining buffer before copying or advancing pointers.

    Seen in 3 reports
  22. Check for integer overflow when multiplying counts by structure sizes before allocating.

    Seen in 3 reports
  23. Check for null pointers before dereferencing.

    Seen in 3 reports
  24. Check for underflow before decrementing length counters and allocate arrays based on the number of elements actually parsed.

    Seen in 3 reports
  25. Check integer arithmetic for overflow, wraparound and underflow before using the result.

    Seen in 3 reports
  26. Check multiplications and sums of counts and sizes for integer overflow before allocating buffers.

    Seen in 3 reports
  27. Check object liveness after any call that can run script or destroy the object, and avoid using this afterwards.

    Seen in 3 reports
  28. Check size calculations for overflow and underflow before allocating or writing.

    Seen in 3 reports
  29. Check size calculations for overflow before allocating, and use the checked result for the copy loop.

    Seen in 3 reports
  30. Check that a fallback format is compatible with the original and keep hardened attributes on backend contexts.

    Seen in 3 reports
  31. Check that an object still exists before using it in the parser.

    Seen in 3 reports
  32. Check that an object still exists before using it in xfrm_dev_state_delete, cifs_newfile_info and the HIDPP connect-event path.

    Seen in 3 reports
  33. Check that an object still exists before using or freeing it to prevent use-after-free and double-free.

    Seen in 3 reports
  34. Check that the referenced object still exists before the action handler operates on it.

    Seen in 3 reports
  35. Check that two characters follow a percent sign before shifting the string.

    Seen in 3 reports
  36. Check user-supplied indices and lengths against the actual array or buffer size before access.

    Seen in 3 reports
  37. Correct how objects are handled in memory and re-check references after callbacks that can run script.

    Seen in 3 reports
  38. Correct reference count handling so objects are not freed while still in tables or queues.

    Seen in 3 reports
  39. Detach or clear references when freeing objects, and set freed pointers to null.

    Seen in 3 reports
  40. Hold a reference or lock around objects for their whole lifetime and check existence before use after free.

    Seen in 3 reports
  41. Hold a reference to objects while callbacks can run.

    Seen in 3 reports
  42. Improve bounds checking and input validation before writing to memory buffers while parsing images.

    Seen in 3 reports
  43. Improve input validation when parsing media and document files so malformed fields cannot drive memory corruption.

    Seen in 3 reports
  44. Improve memory handling and memory management to prevent double frees and corruption.

    Seen in 3 reports
  45. Initialise pointers before use and validate user-supplied values before treating them as pointers.

    Seen in 3 reports
  46. Initialise resources before use so uninitialised memory is never read.

    Seen in 3 reports
  47. Initialise variables and pointers before use, including mapping structures passed to unmap.

    Seen in 3 reports
  48. Keep type and side-effect assumptions sound when optimising, including across reoptimisation.

    Seen in 3 reports
  49. Parsers should validate the length and content of user-supplied data before copying it into fixed-size buffers.

    Seen in 3 reports
  50. Re-check that an object still exists after synchronous callbacks and nested event loops before dereferencing it.

    Seen in 3 reports