diff options
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 32 |
1 files changed, 18 insertions, 14 deletions
@@ -447,25 +447,29 @@ void mog_httpget_post_accept(int fd, struct mog_accept *ac, */ char *mog_http_path(struct mog_http *http, char *buf) { - char *path = buf + http->_p.path_tip; - size_t len = http->_p.path_end - http->_p.path_tip; - - assert(http->_p.path_end > http->_p.path_tip - && "bad HTTP path from parser"); - - if (! mog_valid_path(path, len)) + if (http->_p.usage_txt) { + errno = EACCES; return NULL; + } else { + char *path = buf + http->_p.path_tip; + size_t len = http->_p.path_end - http->_p.path_tip; - if (http->_p.http_method == MOG_HTTP_METHOD_PUT) { - if (!mog_valid_put_path(path, len)) { - errno = EINVAL; + assert(http->_p.path_end > http->_p.path_tip + && "bad HTTP path from parser"); + + if (! mog_valid_path(path, len)) return NULL; - } - } - path[len] = '\0'; + if (http->_p.http_method == MOG_HTTP_METHOD_PUT) { + if (!mog_valid_put_path(path, len)) { + errno = EINVAL; + return NULL; + } + } - return path; + path[len] = '\0'; + return path; + } } |