• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // commit 543787039098c121917cb5f3e129d84b61afa61b 2013-10-04
2 // setenv should not crash on oom
3 #include <stdlib.h>
4 #include <sys/resource.h>
5 #include <string.h>
6 #include <errno.h>
7 #include "test.h"
8 
main(void)9 int main(void)
10 {
11 	char buf[10000];
12 
13 	if (t_memfill() < 0)
14 		t_error("memfill failed\n");
15 
16 	memset(buf, 'x', sizeof buf);
17 	buf[sizeof buf - 1] = 0;
18 
19 	errno = 0;
20 	if (setenv("TESTVAR", buf, 1) != -1)
21 		t_error("setenv was successful\n");
22 	if (errno != ENOMEM)
23 		t_error("expected ENOMEM, got %s\n", strerror(errno));
24 
25 	return t_status;
26 }
27