From 26c51817f273933f8267fbf83f0ad548166e2b9e Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 24 Mar 2020 17:23:41 +0100 Subject: [PATCH] Print better error if one argument is too long Fixes #6800 --- src/postfork.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/postfork.cpp b/src/postfork.cpp index c98bcd65e..85182f63a 100644 --- a/src/postfork.cpp +++ b/src/postfork.cpp @@ -321,11 +321,18 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const * arg_max = sysconf(_SC_ARG_MAX); if (arg_max > 0) { - format_size_safe(sz2, static_cast(arg_max)); - debug_safe(0, - "The total size of the argument and environment lists %s exceeds the " - "operating system limit of %s.", - sz1, sz2); + if (sz >= static_cast(arg_max)) { + format_size_safe(sz2, static_cast(arg_max)); + debug_safe(0, + "The total size of the argument and environment lists %s exceeds the " + "operating system limit of %s.", + sz1, sz2); + } else { + // MAX_ARG_STRLEN, a linux thing that limits the size of one argument. It's defined in binfmt.h, but + // we don't want to include that just to be able to print the real limit. + debug_safe(0, + "One of your arguments exceeds the operating system's argument length limit."); + } } else { debug_safe(0, "The total size of the argument and environment lists (%s) exceeds the "