Author: Caroline Tice Date: 2023-07-10T16:24:31-07:00 New Revision: 5f6c55836fb4666f3160400dc273deefdac82e06
URL: https://github.com/llvm/llvm-project/commit/5f6c55836fb4666f3160400dc273deefdac82e06 DIFF: https://github.com/llvm/llvm-project/commit/5f6c55836fb4666f3160400dc273deefdac82e06.diff LOG: Revert "[LLDB] Fix buffer overflow problem in DWARFExpression::Evaluate." This reverts commit ee476996bec7f170928505a4c5b7715183cfbada. That commit was not the right way to fix the issue (it could result in reading too many bytes). A better fix is in the works. Original review: https://reviews.llvm.org/D153840 Added: Modified: lldb/source/Expression/DWARFExpression.cpp Removed: ################################################################################ diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index c9524870f316f4..2e512bf7581e86 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -1127,16 +1127,15 @@ bool DWARFExpression::Evaluate( if (load_addr == LLDB_INVALID_ADDRESS && so_addr.IsSectionOffset()) { uint8_t addr_bytes[8]; - size_t buf_size = sizeof(addr_bytes); Status error; if (target && - target->ReadMemory(so_addr, &addr_bytes, buf_size, error, - /*force_live_memory=*/false) == buf_size) { + target->ReadMemory(so_addr, &addr_bytes, size, error, + /*force_live_memory=*/false) == size) { ObjectFile *objfile = module_sp->GetObjectFile(); stack.back().GetScalar() = DerefSizeExtractDataHelper( - addr_bytes, size, objfile->GetByteOrder(), buf_size); + addr_bytes, size, objfile->GetByteOrder(), size); stack.back().ClearContext(); break; } else { @@ -1160,13 +1159,13 @@ bool DWARFExpression::Evaluate( lldb::addr_t pointer_addr = stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS); uint8_t addr_bytes[sizeof(lldb::addr_t)]; - size_t buf_size = sizeof(addr_bytes); Status error; - if (process->ReadMemory(pointer_addr, &addr_bytes, buf_size, error) - == buf_size) { + if (process->ReadMemory(pointer_addr, &addr_bytes, size, error) == + size) { + stack.back().GetScalar() = DerefSizeExtractDataHelper(addr_bytes, sizeof(addr_bytes), - process->GetByteOrder(), buf_size); + process->GetByteOrder(), size); stack.back().ClearContext(); } else { if (error_ptr) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits