xref: /third_party/musl/libc-test/src/regression/setenv-oom.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/libc-test/src/regression/
1570af302Sopenharmony_ci// commit 543787039098c121917cb5f3e129d84b61afa61b 2013-10-04
2570af302Sopenharmony_ci// setenv should not crash on oom
3570af302Sopenharmony_ci#include <stdlib.h>
4570af302Sopenharmony_ci#include <sys/resource.h>
5570af302Sopenharmony_ci#include <string.h>
6570af302Sopenharmony_ci#include <errno.h>
7570af302Sopenharmony_ci#include "test.h"
8570af302Sopenharmony_ci
9570af302Sopenharmony_ciint main(void)
10570af302Sopenharmony_ci{
11570af302Sopenharmony_ci	char buf[10000];
12570af302Sopenharmony_ci
13570af302Sopenharmony_ci	if (t_memfill() < 0)
14570af302Sopenharmony_ci		t_error("memfill failed\n");
15570af302Sopenharmony_ci
16570af302Sopenharmony_ci	memset(buf, 'x', sizeof buf);
17570af302Sopenharmony_ci	buf[sizeof buf - 1] = 0;
18570af302Sopenharmony_ci
19570af302Sopenharmony_ci	errno = 0;
20570af302Sopenharmony_ci	if (setenv("TESTVAR", buf, 1) != -1)
21570af302Sopenharmony_ci		t_error("setenv was successful\n");
22570af302Sopenharmony_ci	if (errno != ENOMEM)
23570af302Sopenharmony_ci		t_error("expected ENOMEM, got %s\n", strerror(errno));
24570af302Sopenharmony_ci
25570af302Sopenharmony_ci	_Exit(t_status);
26570af302Sopenharmony_ci	return t_status;
27570af302Sopenharmony_ci}
28

Indexes created Thu Nov 07 10:32:03 CST 2024