[lld] r204420 - [PECOFF] Fix possible response file buffer overrun.

Rui Ueyama ruiu at google.com
Thu Mar 20 17:48:26 PDT 2014


Author: ruiu
Date: Thu Mar 20 19:48:26 2014
New Revision: 204420

URL: http://llvm.org/viewvc/llvm-project?rev=204420&view=rev
Log:
[PECOFF] Fix possible response file buffer overrun.

Response file is not NUL terminated, so when creating a StringRef for
the buffer contents, we need to pass the buffer size as well as the
pointer pointing to the buffer.

Modified:
    lld/trunk/lib/Driver/WinLinkDriver.cpp

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=204420&r1=204419&r2=204420&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Mar 20 19:48:26 2014
@@ -627,7 +627,8 @@ static bool readResponseFile(StringRef p
   ArrayRef<uint8_t> contents;
   if (!readFile(ctx, path, contents))
     return false;
-  StringRef contentsStr(reinterpret_cast<const char *>(contents.data()));
+  StringRef contentsStr(reinterpret_cast<const char *>(contents.data()),
+                        contents.size());
   DriverStringSaver saver(ctx);
   SmallVector<const char *, 0> args;
   llvm::cl::TokenizeWindowsCommandLine(contentsStr, saver, args);





More information about the llvm-commits mailing list