diff options
| author | 2012-04-12 17:45:22 +0000 | |
|---|---|---|
| committer | 2012-04-12 17:45:22 +0000 | |
| commit | 08fd3d5889e09268918e4db39cdaf7623a7d504c (patch) | |
| tree | 622cf7d82d65018215250d28943f236214fdde7e /usr.sbin/nginx/src/core/ngx_string.c | |
| parent | In this case where dup2() extends the table using fdalloc, the newly (diff) | |
| download | wireguard-openbsd-08fd3d5889e09268918e4db39cdaf7623a7d504c.tar.xz wireguard-openbsd-08fd3d5889e09268918e4db39cdaf7623a7d504c.zip | |
use a shared stripping function for chroot and make sure
that the path starts with the chroot prefix before doing anything
with it
Diffstat (limited to 'usr.sbin/nginx/src/core/ngx_string.c')
| -rw-r--r-- | usr.sbin/nginx/src/core/ngx_string.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/usr.sbin/nginx/src/core/ngx_string.c b/usr.sbin/nginx/src/core/ngx_string.c index 1dec96cc4ca..05184479c96 100644 --- a/usr.sbin/nginx/src/core/ngx_string.c +++ b/usr.sbin/nginx/src/core/ngx_string.c @@ -1835,3 +1835,15 @@ ngx_memcpy(void *dst, void *src, size_t n) } #endif + +void +ngx_strip_chroot(ngx_str_t *path) +{ + if (!ngx_strncmp(path->data, NGX_PREFIX, strlen(NGX_PREFIX))) { + char *x, *buf = malloc(path->len); + x = ngx_cpystrn(buf, path->data + strlen(NGX_PREFIX) - 1, + path->len); + path->len = (x - buf); + path->data = buf; + } +} |
