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

Function path_has_dotdot_component

syscall.c:1679–1694  ·  view source on GitHub ↗

Returns 1 if path has any "/"-separated component that is exactly * "..", 0 otherwise. Used by secure_relative_open's front-door * validation to reject inputs that the per-component walk fallback * would otherwise resolve through ".." -- e.g. bare "..", "foo/..", * "subdir/.." -- which RESOLVE_BENEATH-equivalent kernels reject in * the kernel but the per-component fallback (NetBSD/OpenBSD/Sol

Source from the content-addressed store, hash-verified

1677 * the kernel but the per-component fallback (NetBSD/OpenBSD/Solaris/
1678 * Cygwin/pre-5.6 Linux) does not. */
1679static int path_has_dotdot_component(const char *path)
1680{
1681 const char *p = path;
1682
1683 while (*p) {
1684 const char *q;
1685 if (*p == '/') { p++; continue; }
1686 q = p;
1687 while (*q && *q != '/')
1688 q++;
1689 if (q - p == 2 && p[0] == '.' && p[1] == '.')
1690 return 1;
1691 p = q;
1692 }
1693 return 0;
1694}
1695
1696#if defined(__linux__) && defined(HAVE_OPENAT2)
1697/* openat2(RESOLVE_BENEATH) via the raw syscall, gated on openat2_usable() so a

Callers 1

secure_relative_openFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected