(root)/
strace-6.5/
tests/
umovestr-illptr.c
       1  /*
       2   * Check decoding of invalid pointer by umovestr.
       3   *
       4   * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@strace.io>
       5   * Copyright (c) 2016-2021 The strace developers.
       6   * All rights reserved.
       7   *
       8   * SPDX-License-Identifier: GPL-2.0-or-later
       9   */
      10  
      11  #include "tests.h"
      12  #include <stdio.h>
      13  #include <unistd.h>
      14  #include "scno.h"
      15  
      16  int
      17  main(void)
      18  {
      19  	if (F8ILL_KULONG_SUPPORTED) {
      20  		const void *const p = tail_memdup(".", 2);
      21  		long rc = syscall(__NR_chdir, p);
      22  		printf("chdir(\".\") = %s\n", sprintrc(rc));
      23  
      24  		const kernel_ulong_t ill = f8ill_ptr_to_kulong(p);
      25  		rc = syscall(__NR_chdir, ill);
      26  		printf("chdir(%#llx) = %s\n",
      27  		       (unsigned long long) ill, sprintrc(rc));
      28  
      29  		puts("+++ exited with 0 +++");
      30  		return 0;
      31  	} else {
      32  		return 77;
      33  	}
      34  }