[all-commits] [llvm/llvm-project] 62c747: Check if null buffer handed to SBProcess::ReadMemory

Jason Molenda via All-commits all-commits at lists.llvm.org
Tue Feb 7 14:16:20 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 62c747517cd9a0d57f198e0fd0984f71fe75240f
      https://github.com/llvm/llvm-project/commit/62c747517cd9a0d57f198e0fd0984f71fe75240f
  Author: Jason Molenda <jason at molenda.com>
  Date:   2023-02-07 (Tue, 07 Feb 2023)

  Changed paths:
    M lldb/source/API/SBProcess.cpp
    M lldb/test/API/python_api/process/TestProcessAPI.py

  Log Message:
  -----------
  Check if null buffer handed to SBProcess::ReadMemory

Add a check for a null destination buffer in SBProcess::ReadMemory,
and return an error if that happens.  If a Python SB API script
tries to allocate a huge amount of memory, the malloc done by the
intermediate layers will fail and will hand a null pointer to
ReadMemory.  lldb will eventually crash trying to write in to that
buffer.

Also add a test that tries to allocate an impossibly large amount
of memory, and hopefully should result in a failed malloc and hitting
this error codepath.

Differential Revision: https://reviews.llvm.org/D143012
rdar://104846609




More information about the All-commits mailing list