diff options
author | Unbit <info@unbit.it> | 2013-03-12 15:56:30 +0100 |
---|---|---|
committer | Unbit <info@unbit.it> | 2013-03-12 15:56:30 +0100 |
commit | 274eae27efc2c131af1a95271a4f8ecd0c1d7e3e (patch) | |
tree | 1b44958d902e69a1bedd31d1210d9e496611a5d6 /core/protocol.c | |
parent | 207220bc50bc5d7608098181e679e2838c8cfcb4 (diff) | |
download | uwsgi-274eae27efc2c131af1a95271a4f8ecd0c1d7e3e.tar.gz |
fixed requets overwrite in PATH_INFO rewrite
Diffstat (limited to 'core/protocol.c')
-rw-r--r-- | core/protocol.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/protocol.c b/core/protocol.c index b4710b5a..7c5033a2 100644 --- a/core/protocol.c +++ b/core/protocol.c @@ -961,9 +961,24 @@ int uwsgi_hooked_parse_array(char *buffer, size_t len, void (*hook) (uint16_t, c } +/* + +the followign functions need to take in account that POST data could be already available in wsgi_req->buffer (generally when uwsgi protocol is in use) + +In such a case, allocate a proto purser_buf and move data there + +*/ char *uwsgi_req_append(struct wsgi_request *wsgi_req, char *key, uint16_t keylen, char *val, uint16_t vallen) { + if (!wsgi_req->proto_parser_buf) { + if (wsgi_req->proto_parser_remains > 0) { + wsgi_req->proto_parser_buf = uwsgi_malloc(wsgi_req->proto_parser_remains); + memcpy(wsgi_req->proto_parser_buf, wsgi_req->proto_parser_remains_buf, wsgi_req->proto_parser_remains); + wsgi_req->proto_parser_remains_buf = wsgi_req->proto_parser_buf; + } + } + if ((wsgi_req->uh->pktsize + (2 + keylen + 2 + vallen)) > uwsgi.buffer_size) { uwsgi_log("not enough buffer space to add %.*s variable, consider increasing it with the --buffer-size option\n", keylen, key); return NULL; @@ -1001,6 +1016,15 @@ char *uwsgi_req_append(struct wsgi_request *wsgi_req, char *key, uint16_t keylen } int uwsgi_req_append_path_info_with_index(struct wsgi_request *wsgi_req, char *index, uint16_t index_len) { + + if (!wsgi_req->proto_parser_buf) { + if (wsgi_req->proto_parser_remains > 0) { + wsgi_req->proto_parser_buf = uwsgi_malloc(wsgi_req->proto_parser_remains); + memcpy(wsgi_req->proto_parser_buf, wsgi_req->proto_parser_remains_buf, wsgi_req->proto_parser_remains); + wsgi_req->proto_parser_remains_buf = wsgi_req->proto_parser_buf; + } + } + uint8_t need_slash = 0; if (wsgi_req->path_info_len > 0) { if (wsgi_req->path_info[wsgi_req->path_info_len-1] != '/') { |