Mercurial > hg > nginx-quic
changeset 2744:e50a2faac31d
ngx_path_separator()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 23 Apr 2009 16:38:59 +0000 |
parents | d8316f307b6a |
children | 1983932b8075 |
files | src/http/ngx_http_parse.c src/http/ngx_http_request.c src/os/unix/ngx_files.h src/os/win32/ngx_files.h |
diffstat | 4 files changed, 10 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -1337,12 +1337,7 @@ ngx_http_parse_unsafe_uri(ngx_http_reque goto unsafe; } - if (p[0] == '.' && len == 3 && p[1] == '.' && (p[2] == '/' -#if (NGX_WIN32) - || p[2] == '\\' -#endif - )) - { + if (p[0] == '.' && len == 3 && p[1] == '.' && (ngx_path_separator(p[2]))) { goto unsafe; } @@ -1367,30 +1362,22 @@ ngx_http_parse_unsafe_uri(ngx_http_reque continue; } - if ((ch == '/' -#if (NGX_WIN32) - || ch == '\\' -#endif - ) && len > 2) - { + if (ngx_path_separator(ch) && len > 2) { + /* detect "/../" */ - if (p[0] == '.' && p[1] == '.' && p[2] == '/') { + if (p[0] == '.' && p[1] == '.' && ngx_path_separator(p[2])) { goto unsafe; } #if (NGX_WIN32) - if (p[2] == '\\') { - goto unsafe; - } - if (len > 3) { /* detect "/.../" */ if (p[0] == '.' && p[1] == '.' && p[2] == '.' - && (p[3] == '/' || p[3] == '\\')) + && ngx_path_separator(p[3])) { goto unsafe; }
--- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1587,15 +1587,9 @@ ngx_http_validate_host(u_char *host, siz continue; } - if (ch == '/' || ch == '\0') { + if (ngx_path_separator(ch) || ch == '\0') { return -1; } - -#if (NGX_WIN32) - if (ch == '\\') { - return -1; - } -#endif } if (dot) {
--- a/src/os/unix/ngx_files.h +++ b/src/os/unix/ngx_files.h @@ -160,6 +160,8 @@ ngx_int_t ngx_set_file_time(u_char *name #define ngx_realpath_n "realpath()" #define ngx_getcwd(buf, size) (getcwd(buf, size) != NULL) #define ngx_getcwd_n "getcwd()" +#define ngx_path_separator(c) ((c) == '/') + #define NGX_MAX_PATH PATH_MAX #define NGX_DIR_MASK_LEN 0
--- a/src/os/win32/ngx_files.h +++ b/src/os/win32/ngx_files.h @@ -154,6 +154,8 @@ char *ngx_realpath(u_char *path, u_char #define ngx_realpath_n "" #define ngx_getcwd(buf, size) GetCurrentDirectory(size, buf) #define ngx_getcwd_n "GetCurrentDirectory()" +#define ngx_path_separator(c) ((c) == '/' || (c) == '\\') + #define NGX_MAX_PATH MAX_PATH