pargs crashes on growing env
I've seen some strange pargs core dumps. Sometimes pargs dies when the target process adds environment variables. The problem is in get_env() and build_env(). We iterate two times over the environment strings. The first time to check the number of elements in order to determine the buffer size. Then we allocate the buffer and iterate again to fill this buffer. Meanwhile the target process has added some strings to the environment and the second iteration would fill too many strings into the buffer. There is no overflow protection.
I've attached a little reproducer.