[llvm-branch-commits] [lld] r341780 - Merging r341670 and r341672:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 10 00:55:48 PDT 2018


Author: hans
Date: Mon Sep 10 00:55:48 2018
New Revision: 341780

URL: http://llvm.org/viewvc/llvm-project?rev=341780&view=rev
Log:
Merging r341670 and r341672:
------------------------------------------------------------------------
r341670 | tstellar | 2018-09-07 17:42:01 +0200 (Fri, 07 Sep 2018) | 15 lines

MachO: Fix out-of-bounds memory access in getString16

Summary:
This fixes the following tests when gcc is compiled with gcc8:

lld :: mach-o/do-not-emit-unwind-fde-arm64.yaml
lld :: mach-o/eh-frame-relocs-arm64.yaml

llvm.org/PR38096

Reviewers: lhames, kledzik, javed.absar

Subscribers: kristof.beyls, llvm-commits

Differential Revision: https://reviews.llvm.org/D51547
------------------------------------------------------------------------

------------------------------------------------------------------------
r341672 | tstellar | 2018-09-07 17:51:52 +0200 (Fri, 07 Sep 2018) | 3 lines

MachO: Change getString16() back to inline function

This was accidentally changed in r341670.
------------------------------------------------------------------------

Modified:
    lld/branches/release_70/   (props changed)
    lld/branches/release_70/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h

Propchange: lld/branches/release_70/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep 10 00:55:48 2018
@@ -1 +1 @@
-/lld/trunk:338679,338684,338697,338699,338877,338911,339049,339058,339075,339165,339253,339904
+/lld/trunk:338679,338684,338697,338699,338877,338911,339049,339058,339075,339165,339253,339904,341670,341672

Modified: lld/branches/release_70/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_70/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h?rev=341780&r1=341779&r2=341780&view=diff
==============================================================================
--- lld/branches/release_70/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h (original)
+++ lld/branches/release_70/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h Mon Sep 10 00:55:48 2018
@@ -186,11 +186,10 @@ packRelocation(const Relocation &r, bool
 }
 
 inline StringRef getString16(const char s[16]) {
-  StringRef x = s;
-  if ( x.size() > 16 )
-    return x.substr(0, 16);
-  else
-    return x;
+  // The StringRef(const char *) constructor passes the const char * to
+  // strlen(), so we can't use this constructor here, because if there is no
+  // null terminator in s, then strlen() will read past the end of the array.
+  return StringRef(s, strnlen(s, 16));
 }
 
 inline void setString16(StringRef str, char s[16]) {




More information about the llvm-branch-commits mailing list