MCPcopy Index your code
hub / github.com/RsyncProject/rsync / check_relpath

Function check_relpath

t_secure_relpath.c:44–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42static int errs = 0;
43
44static 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
73static void check_basedir(const char *basedir)
74{

Callers 1

mainFunction · 0.85

Calls 2

secure_relative_openFunction · 0.85
strerrorFunction · 0.85

Tested by

no test coverage detected