This revision was automatically updated to reflect the committed changes. Closed by commit rL353280: Fix strlen() of unbound array undefined behavior (authored by jankratochvil, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D57781?vs=185373&id=185498#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57781/new/ https://reviews.llvm.org/D57781 Files: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Utility/ConstString.cpp Index: lldb/trunk/source/Utility/ConstString.cpp =================================================================== --- lldb/trunk/source/Utility/ConstString.cpp +++ lldb/trunk/source/Utility/ConstString.cpp @@ -143,7 +143,7 @@ const char *GetConstTrimmedCStringWithLength(const char *cstr, size_t cstr_len) { if (cstr != nullptr) { - const size_t trimmed_len = std::min<size_t>(strlen(cstr), cstr_len); + const size_t trimmed_len = strnlen(cstr, cstr_len); return GetConstCStringWithLength(cstr, trimmed_len); } return nullptr; Index: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp =================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1609,8 +1609,7 @@ bool add_section = true; bool add_to_unified = true; ConstString const_segname( - load_cmd.segname, - std::min<size_t>(strlen(load_cmd.segname), sizeof(load_cmd.segname))); + load_cmd.segname, strnlen(load_cmd.segname, sizeof(load_cmd.segname))); SectionSP unified_section_sp( context.UnifiedList.FindSectionByName(const_segname)); @@ -1729,8 +1728,7 @@ if (add_section) { ConstString section_name( - sect64.sectname, - std::min<size_t>(strlen(sect64.sectname), sizeof(sect64.sectname))); + sect64.sectname, strnlen(sect64.sectname, sizeof(sect64.sectname))); if (!const_segname) { // We have a segment with no name so we need to conjure up segments // that correspond to the section's segname if there isn't already such
Index: lldb/trunk/source/Utility/ConstString.cpp =================================================================== --- lldb/trunk/source/Utility/ConstString.cpp +++ lldb/trunk/source/Utility/ConstString.cpp @@ -143,7 +143,7 @@ const char *GetConstTrimmedCStringWithLength(const char *cstr, size_t cstr_len) { if (cstr != nullptr) { - const size_t trimmed_len = std::min<size_t>(strlen(cstr), cstr_len); + const size_t trimmed_len = strnlen(cstr, cstr_len); return GetConstCStringWithLength(cstr, trimmed_len); } return nullptr; Index: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp =================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1609,8 +1609,7 @@ bool add_section = true; bool add_to_unified = true; ConstString const_segname( - load_cmd.segname, - std::min<size_t>(strlen(load_cmd.segname), sizeof(load_cmd.segname))); + load_cmd.segname, strnlen(load_cmd.segname, sizeof(load_cmd.segname))); SectionSP unified_section_sp( context.UnifiedList.FindSectionByName(const_segname)); @@ -1729,8 +1728,7 @@ if (add_section) { ConstString section_name( - sect64.sectname, - std::min<size_t>(strlen(sect64.sectname), sizeof(sect64.sectname))); + sect64.sectname, strnlen(sect64.sectname, sizeof(sect64.sectname))); if (!const_segname) { // We have a segment with no name so we need to conjure up segments // that correspond to the section's segname if there isn't already such
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits