[PATCH] D83772: [Windows] Fix limit on command line size

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 07:22:37 PDT 2020


sepavloff created this revision.
sepavloff added reviewers: rnk, zturner.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Documentation on CreateProcessW states that maximal size of command line
is 32767 characters including ternimation null character. In the
function llvm::sys::commandLineFitsWithinSystemLimits this limit was set
to 32768. As a result if command line was exactly 32768 characters long,
a response file was not created and CreateProcessW was called with
too long command line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83772

Files:
  llvm/lib/Support/Windows/Program.inc


Index: llvm/lib/Support/Windows/Program.inc
===================================================================
--- llvm/lib/Support/Windows/Program.inc
+++ llvm/lib/Support/Windows/Program.inc
@@ -532,8 +532,13 @@
 
 bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
                                                   ArrayRef<StringRef> Args) {
-  // The documented max length of the command line passed to CreateProcess.
-  static const size_t MaxCommandStringLength = 32768;
+  // In the documentation on CreateProcessW:
+  // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
+  // it is stated that the argument lpCommandLine has restriction:
+  //
+  //    The maximum length of this string is 32,767 characters, including the
+  //    Unicode terminating null character.
+  static const size_t MaxCommandStringLength = 32767;
   SmallVector<StringRef, 8> FullArgs;
   FullArgs.push_back(Program);
   FullArgs.append(Args.begin(), Args.end());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83772.277825.patch
Type: text/x-patch
Size: 1025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200714/9659f218/attachment.bin>


More information about the llvm-commits mailing list