From 52577c0a69ef28d959807298070aafb3c0e338cd Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Fri, 14 Jul 2017 17:11:54 -0700 Subject: [PATCH] [CLI] don't allow the Java buck integration to store too much data in an environment var Reviewed By: jeremydubreil Differential Revision: D5424791 fbshipit-source-id: 91713ef --- infer/src/base/CommandLineOption.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/infer/src/base/CommandLineOption.ml b/infer/src/base/CommandLineOption.ml index 9aa3da250..c179fb902 100644 --- a/infer/src/base/CommandLineOption.ml +++ b/infer/src/base/CommandLineOption.ml @@ -826,7 +826,13 @@ let parse ?config_file ~usage action initial_command = let curr_usage = parse_args ~usage action ?initial_command cl_args in add_parsed_args_to_args_to_export () ; curr_usage in - Unix.putenv ~key:args_env_var ~data:!args_to_export ; + (* we have to be careful not to add too much data to the environment because the size of the + environment contributes to the length of the command to be run. if the environment + CLI is too + big, running any command will fail with a cryptic "exit code 127" error. here, we hack around the + issue by refusing to add a string to the environment if it's sufficiently big (and praying that + this won't make the command fail). TODO (t20145863): use argfiles here *) + if List.is_empty !extra_env_args || String.length !args_to_export < 100000 then + Unix.putenv ~key:args_env_var ~data:!args_to_export ; (!curr_command, curr_usage) let wrap_line indent_string wrap_length line0 =