| 42 | static int errs = 0; |
| 43 | |
| 44 | static void check_relpath(const char *relpath) |
| 45 | { |
| 46 | int fd; |
| 47 | int saved_errno; |
| 48 | |
| 49 | errno = 0; |
| 50 | fd = secure_relative_open(NULL, relpath, O_RDONLY | O_DIRECTORY, 0); |
| 51 | saved_errno = errno; |
| 52 | |
| 53 | if (fd >= 0) { |
| 54 | fprintf(stderr, |
| 55 | "FAIL [relpath=%-12s]: returned valid fd %d (escape) -- expected -1 EINVAL\n", |
| 56 | relpath, fd); |
| 57 | close(fd); |
| 58 | errs++; |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | if (saved_errno != EINVAL) { |
| 63 | fprintf(stderr, |
| 64 | "FAIL [relpath=%-12s]: rejected but errno=%d (%s), expected EINVAL\n", |
| 65 | relpath, saved_errno, strerror(saved_errno)); |
| 66 | errs++; |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | fprintf(stderr, "OK [relpath=%-12s]: rejected with EINVAL\n", relpath); |
| 71 | } |
| 72 | |
| 73 | static void check_basedir(const char *basedir) |
| 74 | { |
no test coverage detected