|
wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
|
Resolve an HTTP request path into a document-root-relative file path for static file serving (quiche-server's –root/–index), rejecting path traversal. More...
#include "common/platform/sys/syscall.h"Go to the source code of this file.
Functions | |
| int | wired_staticfile_has_traversal (const char *path) |
| 1 if path contains a ".." path-traversal segment: "/../", a leading "../", or a trailing "/..". | |
| int | wired_staticfile_resolve (const char *root, const char *reqpath, const char *index, char *out, usz outcap) |
| Resolve reqpath against root into out, rejecting traversal. | |
Resolve an HTTP request path into a document-root-relative file path for static file serving (quiche-server's –root/–index), rejecting path traversal.
Socket- and filesystem-free: string manipulation only, the caller opens the resolved path (e.g. via wired_fio_read).
| int wired_staticfile_has_traversal | ( | const char * | path | ) |
1 if path contains a ".." path-traversal segment: "/../", a leading "../", or a trailing "/..".
A ".." that is merely a substring of a longer segment (e.g. "foo..bar.txt") is NOT flagged.
| path | NUL-terminated request path |
| int wired_staticfile_resolve | ( | const char * | root, |
| const char * | reqpath, | ||
| const char * | index, | ||
| char * | out, | ||
| usz | outcap ) |
Resolve reqpath against root into out, rejecting traversal.
root is always prefixed (no absolute-path double interpretation). If reqpath is empty or ends in "/", index is appended as the file name (e.g. root="/www", reqpath="/", index="index.html" -> "/www/index.html").
| root | NUL-terminated document root, no trailing slash |
| reqpath | NUL-terminated request path, e.g. "/foo/bar.txt" |
| index | NUL-terminated index file name used when reqpath names a directory (empty or trailing "/") |
| out | destination buffer for the resolved, NUL-terminated path |
| outcap | capacity of out in bytes, including the NUL terminator |