crash-fcntl-invalid-cmd.cpp 554 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Copyright (c) 2020, Ben Wiederhake <BenWiederhake.GitHub@gmx.de>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <assert.h>
  7. #include <errno.h>
  8. #include <fcntl.h>
  9. #include <stdio.h>
  10. #include <unistd.h>
  11. int main(int, char**)
  12. {
  13. int rc = fcntl(0, -42);
  14. if (rc != -1) {
  15. printf("FAIL: rc was %d, instead of -1\n", rc);
  16. return 1;
  17. } else if (errno != EINVAL) {
  18. printf("FAIL: errno was %d, instead of EINVAL=%d\n", errno, EINVAL);
  19. return 1;
  20. } else {
  21. printf("PASS\n");
  22. }
  23. return 0;
  24. }