minijail0_cli_unittest: fix random crashes/failures

The GNU getopt API cannot handle being passed different argv vectors
by default.  Changing optind back to 1 will trigger a reset of state,
but only relative to the previous argv getopt saw.  Instead, optind
has to be set to 0 so all internal state is reset.  This extension is
from GNU (glibc), but Android's bionic also supports it.

Otherwise, when we pass in a different argv, the internal state might
randomly refer to the old argv memory which in turn can lead to random
errors or memory violations.

Bug: None
Test: `./minijail0_cli_unittest --gtest_repeat=-1` no longer randomly crashes
Change-Id: I79276518bb51e297719049c7efa9824d6f97c7ab
1 file changed