Merge pull request #987 from asottile/no_sc_arg_max

Bound maxsize by 4096 when SC_ARG_MAX is not present
This commit is contained in:
Anthony Sottile 2019-04-01 09:42:44 -07:00 committed by GitHub
commit 6302dec938
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,7 +25,7 @@ def _environ_size(_env=None):
def _get_platform_max_length(): # pragma: no cover (platform specific)
if os.name == 'posix':
maximum = os.sysconf(str('SC_ARG_MAX')) - 2048 - _environ_size()
maximum = min(maximum, 2 ** 17)
maximum = max(min(maximum, 2 ** 17), 2 ** 12)
return maximum
elif os.name == 'nt':
return 2 ** 15 - 2048 # UNICODE_STRING max - headroom