vlc | branch: master | Pierre Ynard <[email protected]> | Sat Dec 11 00:58:18 2010 +0100| [2e1b9e44719618eb97b3850d05096753fd7d3617] | committer: Pierre Ynard
httpd: gracefully handle too large request bodies Return a 413 error instead of crashing > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2e1b9e44719618eb97b3850d05096753fd7d3617 --- src/network/httpd.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/src/network/httpd.c b/src/network/httpd.c index 3eaa8c5..ddcbb3d 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -1832,8 +1832,31 @@ static void httpd_ClientRecv( httpd_client_t *cl ) /* TODO Mhh, handle the case where the client only * sends a request and closes the connection to * mark the end of the body (probably only RTSP) */ - cl->query.p_body = xmalloc( cl->query.i_body ); + cl->query.p_body = malloc( cl->query.i_body ); cl->i_buffer = 0; + if ( cl->query.p_body == NULL ) + { + switch (cl->query.i_proto) + { + case HTTPD_PROTO_HTTP: + { + const uint8_t sorry[] = + "HTTP/1.1 413 Request Entity Too Large\r\n\r\n"; + httpd_NetSend( cl, sorry, sizeof( sorry ) - 1 ); + break; + } + case HTTPD_PROTO_RTSP: + { + const uint8_t sorry[] = + "RTSP/1.0 413 Request Entity Too Large\r\n\r\n"; + httpd_NetSend( cl, sorry, sizeof( sorry ) - 1 ); + break; + } + default: + assert( 0 ); + } + i_len = 0; /* drop */ + } break; } else _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
