[vlc-commits] commit: httpd: gracefully handle too large request bodies (Pierre Ynard )
git at videolan.org
git at videolan.org
Sat Dec 11 01:09:04 CET 2010
vlc/vlc-1.1 | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sat Dec 11 00:58:18 2010 +0100| [879b6278414d2370748ccd61cc8c970b04b28171] | committer: Pierre Ynard
httpd: gracefully handle too large request bodies
Return a 413 error instead of crashing
(cherry picked from commit 2e1b9e44719618eb97b3850d05096753fd7d3617)
Signed-off-by: Pierre Ynard <linkfanel at yahoo.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=879b6278414d2370748ccd61cc8c970b04b28171
---
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
More information about the vlc-commits
mailing list