mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-06 15:51:25 +00:00
Added sanity checking in send_file_data()
This commit is contained in:
1 parent
ab16220861
commit
94e1c5a41b
1 file changed
+3
@@ -2727,6 +2727,9 @@ static void send_file_data(struct mg_connection *conn, struct file *filep,
|
|||||||
char buf[MG_BUF_LEN];
|
char buf[MG_BUF_LEN];
|
||||||
int to_read, num_read, num_written;
|
int to_read, num_read, num_written;
|
||||||
|
|
||||||
|
// Sanity check the offset
|
||||||
|
offset = offset < 0 ? 0 : offset > filep->size ? filep->size : offset;
|
||||||
|
|
||||||
if (len > 0 && filep->membuf != NULL && filep->size > 0) {
|
if (len > 0 && filep->membuf != NULL && filep->size > 0) {
|
||||||
if (len > filep->size - offset) {
|
if (len > filep->size - offset) {
|
||||||
len = filep->size - offset;
|
len = filep->size - offset;
|
||||||
|
|||||||
Reference in new issue
Block a user