crash-fcntl-invalid-cmd.cpp 574 B

123456789101112131415161718192021222324252627
  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 <stdlib.h>
  11. #include <unistd.h>
  12. int main(int, char**)
  13. {
  14. int rc = fcntl(0, -42);
  15. if (rc != -1) {
  16. printf("FAIL: rc was %d, instead of -1\n", rc);
  17. return 1;
  18. } else if (errno != EINVAL) {
  19. printf("FAIL: errno was %d, instead of EINVAL=%d\n", errno, EINVAL);
  20. return 1;
  21. } else {
  22. printf("PASS\n");
  23. }
  24. return 0;
  25. }