mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
prefix was missing /; malformed request caused server to crash
svn:r256
This commit is contained in:
parent
9d9d60b1ff
commit
44bd5ab4e0
1
evhttp.h
1
evhttp.h
@ -52,6 +52,7 @@ typedef unsigned char u_char;
|
||||
#define HTTP_OK 200
|
||||
#define HTTP_MOVEPERM 301
|
||||
#define HTTP_MOVETEMP 302
|
||||
#define HTTP_BADREQUEST 400
|
||||
#define HTTP_NOTFOUND 404
|
||||
#define HTTP_SERVUNAVAIL 503
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
struct evrpc;
|
||||
|
||||
#define EVRPC_URI_PREFIX ".rpc."
|
||||
#define EVRPC_URI_PREFIX "/.rpc."
|
||||
|
||||
struct evrpc_base {
|
||||
/* the HTTP server under which we register our RPC calls */
|
||||
|
4
evrpc.c
4
evrpc.c
@ -165,10 +165,10 @@ error:
|
||||
void
|
||||
evrpc_reqstate_free(struct evrpc_req_generic* rpc_state)
|
||||
{
|
||||
struct evrpc *rpc = rpc_state->rpc;
|
||||
|
||||
/* clean up all memory */
|
||||
if (rpc_state != NULL) {
|
||||
struct evrpc *rpc = rpc_state->rpc;
|
||||
|
||||
if (rpc_state->request != NULL)
|
||||
rpc->request_free(rpc_state);
|
||||
if (rpc_state->reply != NULL)
|
||||
|
22
http.c
22
http.c
@ -324,14 +324,23 @@ evhttp_connection_fail(struct evhttp_connection *evcon)
|
||||
struct evhttp_request* req = TAILQ_FIRST(&evcon->requests);
|
||||
assert(req != NULL);
|
||||
|
||||
/* reset the connection */
|
||||
evhttp_connection_reset(evcon);
|
||||
|
||||
if (req->cb != NULL) {
|
||||
/* xxx: maybe we need to pass the request here? */
|
||||
/*
|
||||
* we are passing the request object if we have an incoming
|
||||
* request that somehow needs to be answered. we need to
|
||||
* wait for the answer to travel over the wire before we can
|
||||
* kill the connection.
|
||||
*/
|
||||
if (evcon->flags & EVHTTP_CON_INCOMING) {
|
||||
(*req->cb)(req, req->cb_arg);
|
||||
return;
|
||||
}
|
||||
(*req->cb)(NULL, req->cb_arg);
|
||||
}
|
||||
|
||||
/* reset the connection */
|
||||
evhttp_connection_reset(evcon);
|
||||
|
||||
TAILQ_REMOVE(&evcon->requests, req, next);
|
||||
evhttp_request_free(req);
|
||||
|
||||
@ -1237,6 +1246,11 @@ evhttp_handle_request(struct evhttp_request *req, void *arg)
|
||||
struct evhttp *http = arg;
|
||||
struct evhttp_cb *cb;
|
||||
|
||||
if (req->uri == NULL) {
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Test for different URLs */
|
||||
TAILQ_FOREACH(cb, &http->callbacks, next) {
|
||||
int res;
|
||||
|
Loading…
x
Reference in New Issue
Block a user