(root)/
strace-6.5/
tests/
umovestr2.c
       1  /*
       2   * Copyright (c) 2015-2021 Dmitry V. Levin <ldv@strace.io>
       3   * All rights reserved.
       4   *
       5   * SPDX-License-Identifier: GPL-2.0-or-later
       6   */
       7  
       8  #include "tests.h"
       9  #include <stdio.h>
      10  #include <string.h>
      11  #include <unistd.h>
      12  
      13  int
      14  main(void)
      15  {
      16  	const size_t page_len = get_page_size();
      17  	const size_t tail_len = page_len * 2 - 1;
      18  	const size_t str_len = tail_len - 1;
      19  
      20  	char *addr = tail_alloc(tail_len);
      21  	memset(addr, '0', str_len);
      22  	addr[str_len] = '\0';
      23  
      24  	char *argv[] = { NULL };
      25  	char *envp[] = { addr, NULL };
      26  	execve("", argv, envp);
      27  
      28  	printf("execve(\"\", [], [\"%0*u\"]) = -1 ENOENT (%m)\n",
      29  	       (int) str_len, 0);
      30  	puts("+++ exited with 0 +++");
      31  
      32  	return 0;
      33  }