]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r268576: sh: Correctly handle positional parameters beyond INT_MAX on
authorjilles <jilles@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Sun, 14 Dec 2014 18:30:30 +0000 (18:30 +0000)
committerjilles <jilles@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Sun, 14 Dec 2014 18:30:30 +0000 (18:30 +0000)
commitefe464b659a5482f1b5db924c97278726f590bb3
tree7e89843a2c631463f878a11fbbc2bfc9afddd525
parent7a86c81ebc4bfd43a6e9d75adf7c3df6e5cc49dc
MFC r268576: sh: Correctly handle positional parameters beyond INT_MAX on
64-bit systems.

Currently, there can be no more than INT_MAX positional parameters. Make
sure to treat all higher ones as unset to avoid incorrect results and
crashes.

On 64-bit systems, our atoi() takes the low 32 bits of the strtol() and
sign-extends them.

On 32-bit systems, the call to atoi() returned INT_MAX for too high values
and there is not enough address space for so many positional parameters, so
there was no issue.

PR: 195918

git-svn-id: svn://svn.freebsd.org/base/stable/10@275777 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
bin/sh/expand.c
bin/sh/tests/parameters/Makefile
bin/sh/tests/parameters/positional5.0 [new file with mode: 0644]