Advertisement
programjm

array overread/overwrite

Jul 15th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. (require memcheck)
  2.  
  3. (defun malloc-max () (+ *malloc-arena-start* *malloc-max-arena-size*))
  4.  
  5. (defmethod init ()
  6. (msg "*malloc-arena-start* : $0" *malloc-arena-start*)
  7. (msg "*malloc-arena-end* : $0" *malloc-arena-end*)
  8. (msg "*malloc-max-arena-size : $0" *malloc-max-arena-size*)
  9. (msg "malloc max end : $0" (malloc-max))
  10. (msg "brk : $0" brk))
  11.  
  12. (defun out-of-bounds/check (ptr)
  13. (let ((malloc-lower-bound *malloc-arena-start*)
  14. (malloc-upper-bound (malloc-max)))
  15. (when (and
  16. (>= ptr malloc-lower-bound)
  17. (<= ptr malloc-upper-bound)
  18. (not (region-contains 'memcheck/live/malloc ptr)))
  19. (msg "ptr: $0 malloc-lower-bound: $1 malloc-upper-bound: $2" ptr malloc-lower-bound malloc-upper-bound)
  20. (msg "out of bounds")
  21. (incident-report 'out-of-bounds (incident-location)))))
  22.  
  23. (defmethod loaded (ptr)
  24. (msg "loaded $0, malloc: [$1..$2]" ptr *malloc-arena-start* brk)
  25. (out-of-bounds/check ptr))
  26.  
  27. (defmethod stored (ptr)
  28. (msg "stored $0, malloc: [$1..$2]" ptr *malloc-arena-start* brk)
  29. (out-of-bounds/check ptr))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement