|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Shared filesystem path helpers for the file-transfer servers (SFTP / SCP, and the pattern the static file server + WebDAV also use): join a mount root with a request subpath and reject .. traversal - the single choke point that keeps a request from escaping its mount.
More...
#include "protocore_config.h"#include "shared_primitives/strbuf.h"#include <stddef.h>#include <stdio.h>#include <string.h>Go to the source code of this file.
Functions | |
| bool | fs_path_join (const char *root, const char *sub, char *out, size_t cap) |
Join a filesystem root and a sub path into out, normalizing the separator. | |
| int | fs_path_resolve (const char *root, const char *sub, char *out, size_t cap) |
Resolve a mount root + a request sub path to an on-disk path in out: reject any .. traversal, join onto the root, and drop a trailing '/'. | |
Shared filesystem path helpers for the file-transfer servers (SFTP / SCP, and the pattern the static file server + WebDAV also use): join a mount root with a request subpath and reject .. traversal - the single choke point that keeps a request from escaping its mount.
Pure string logic (no fs::FS, no heap, no stdlib) so it is host-testable and identical on device + host. The guard is a substring reject (not realpath/symlink resolution) - the on-flash filesystems (FAT / LittleFS) have no symlinks, so a ..-free joined path cannot escape the root.
Definition in file fs_path.h.
|
inline |
Join a filesystem root and a sub path into out, normalizing the separator.
Definition at line 29 of file fs_path.h.
References pc_sb_finish(), and pc_sb_put().
Referenced by fs_path_resolve().
|
inline |
Resolve a mount root + a request sub path to an on-disk path in out: reject any .. traversal, join onto the root, and drop a trailing '/'.
.. present), -2 if the joined path would overflow out. Definition at line 58 of file fs_path.h.
References fs_path_join().