From 2c00a4da4f450de313c43e6b16632c640d9d0cd6 Mon Sep 17 00:00:00 2001 From: sb1066 Date: Fri, 9 Jul 2010 20:09:53 +0000 Subject: [PATCH] Added sanity checks for http-ranges --- src/webui/webui.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/webui/webui.c b/src/webui/webui.c index 6f90ac97..e3394b28 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -241,6 +241,16 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque) if(range != NULL) sscanf(range, "bytes=%"PRId64"-%"PRId64"", &file_start, &file_end); + //Sanity checks + if(file_start < 0 || file_start >= st.st_size) + return 200; + + if(file_end < 0 || file_end >= st.st_size) + return 200; + + if(file_start > 0 || file_end) + return 200; + content_len = file_end - file_start+1; sprintf(range_buf, "bytes %"PRId64"-%"PRId64"/%"PRId64"", file_start, file_end, st.st_size);