Skip to content

Commit

Permalink
Fix TestGdbRemoteLibrariesSvr4Support
Browse files Browse the repository at this point in the history
D62502 had a bug (visible only with D62503 reverted), where it would
error out if attempting to read a string from memory and the memory page
after the string happened to be unmapped.

This fixes the problem by checking for whether ReadMemory read *any*
bytes, instead of checking whether it returned an error. A greater
question is whether ReadMemory should even return an error if it read at
least one byte, but I'm leaving that for a separate patch.

llvm-svn: 364748
  • Loading branch information
labath committed Jul 1, 2019
1 parent 881aab4 commit 4f0a377
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
Expand Up @@ -120,7 +120,7 @@ NativeProcessELF::ReadSVR4LibraryInfo(lldb::addr_t link_map_addr) {
char name_buffer[PATH_MAX];
error = ReadMemory(link_map.l_name, &name_buffer, sizeof(name_buffer),
bytes_read);
if (!error.Success())
if (bytes_read == 0)
return error.ToError();
name_buffer[PATH_MAX - 1] = '\0';

Expand Down Expand Up @@ -176,4 +176,4 @@ NativeProcessELF::GetLoadedSVR4Libraries() {
return library_list;
}

} // namespace lldb_private
} // namespace lldb_private

0 comments on commit 4f0a377

Please sign in to comment.