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
| 1677 | * the kernel but the per-component fallback (NetBSD/OpenBSD/Solaris/ |
| 1678 | * Cygwin/pre-5.6 Linux) does not. */ |
| 1679 | static 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 |
no outgoing calls
no test coverage detected