diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2023-08-28 16:14:41 +0300 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2023-08-28 18:17:30 +0300 |
commit | 44f73c5a620689d6821c4bd0444051be57f8251a (patch) | |
tree | f4fd09528dfe641d98603d7ac03277eca7158ebf /winsup/cygwin/sysconf.cc | |
parent | 50ff7901a5dbb2c57548d1bc125bbfbd17d37889 (diff) |
Cygwin: Fix segfalt when too many command line args are specified.
Previously, the number of command line args was not checked for
cygwin process. Due to this, segmentation fault was caused if too
many command line args are specified.
https://cygwin.com/pipermail/cygwin/2023-August/254333.html
Since char *argv[argc + 1] is placed on the stack in dll_crt0_1(),
STATUS_STACK_OVERFLOW occurs if the stack does not have enough
space.
With this patch, char *argv[] is placed in heap instead of stack
and ARG_MAX is increased from 32000 to 2097152 which is default
value of Linux. The argument length is also compared with ARG_MAX
and spawnve() returns E2BIG if it is too long.
Reported-by: Ed Morton
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diffstat (limited to 'winsup/cygwin/sysconf.cc')
-rw-r--r-- | winsup/cygwin/sysconf.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index 2db92e4de..7cdfbdb9d 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -485,7 +485,7 @@ static struct }; } sca[] = { - {cons, {c:ARG_MAX}}, /* 0, _SC_ARG_MAX */ + {cons, {c:CYG_ARG_MAX}}, /* 0, _SC_ARG_MAX */ {cons, {c:CHILD_MAX}}, /* 1, _SC_CHILD_MAX */ {cons, {c:CLOCKS_PER_SEC}}, /* 2, _SC_CLK_TCK */ {cons, {c:NGROUPS_MAX}}, /* 3, _SC_NGROUPS_MAX */ |