aboutsummaryrefslogtreecommitdiff
blob: bea0aaafb87169eb2cbffe86ed1704d4b3bc6f46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * A simple wrapper for execv that validates environment
 * is not corrupted by wrapper: https://bugs.gentoo.org/669702
 */

#define _GNU_SOURCE /* for environ */
#include <stdio.h>
#include "tests.h"

int main(int argc, char *argv[])
{
	char* execv_argv[] = {"nope", (char*)NULL,};
	char* execv_environ[] = {"FOO=1", (char*)NULL,};
	environ = execv_environ;
	execv("./does/not/exist", execv_argv);
	if (environ != execv_environ) {
		fprintf(stderr, "environ was changed unexpectedly by execv wrapper\n");
		return 1;
	}
	return 0;
}