Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/c22fbf937756a1b35085a...
...commit
http://git.netsurf-browser.org/netsurf.git/commit/c22fbf937756a1b35085a85...
...tree
http://git.netsurf-browser.org/netsurf.git/tree/c22fbf937756a1b35085a8577...
The branch, master has been updated
via c22fbf937756a1b35085a8577e138bd1dc540eea (commit)
from d5e1616a454ffd1a2e9f7b2abf479f0c1aee4425 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commitdiff/c22fbf937756a1b3508...
commit c22fbf937756a1b35085a8577e138bd1dc540eea
Author: John-Mark Bell <jmb(a)netsurf-browser.org>
Commit: John-Mark Bell <jmb(a)netsurf-browser.org>
Avoid trying to mmap zero-length files.
Remove buf size limit in mmap case: prevented processing entire file.
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index abedaa7..73bfbdb 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -256,7 +256,7 @@ static void fetch_file_process_plain(struct fetch_file_context *ctx,
{
#ifdef HAVE_MMAP
fetch_msg msg;
- char *buf;
+ char *buf = NULL;
size_t buf_size;
int fd; /**< The file descriptor of the object */
@@ -279,17 +279,17 @@ static void fetch_file_process_plain(struct fetch_file_context
*ctx,
/* set buffer size */
buf_size = fdstat->st_size;
- if (buf_size > FETCH_FILE_MAX_BUF_SIZE)
- buf_size = FETCH_FILE_MAX_BUF_SIZE;
/* allocate the buffer storage */
- buf = mmap(NULL, buf_size, PROT_READ, MAP_SHARED, fd, 0);
- if (buf == MAP_FAILED) {
- msg.type = FETCH_ERROR;
- msg.data.error = "Unable to map memory for file data buffer";
- fetch_file_send_callback(&msg, ctx);
- close(fd);
- return;
+ if (buf_size > 0) {
+ buf = mmap(NULL, buf_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (buf == MAP_FAILED) {
+ msg.type = FETCH_ERROR;
+ msg.data.error = "Unable to map memory for file data buffer";
+ fetch_file_send_callback(&msg, ctx);
+ close(fd);
+ return;
+ }
}
/* fetch is going to be successful */
@@ -327,7 +327,8 @@ static void fetch_file_process_plain(struct fetch_file_context *ctx,
fetch_file_process_aborted:
- munmap(buf, buf_size);
+ if (buf != NULL)
+ munmap(buf, buf_size);
close(fd);
#else
fetch_msg msg;
-----------------------------------------------------------------------
Summary of changes:
content/fetchers/file.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index abedaa7..73bfbdb 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -256,7 +256,7 @@ static void fetch_file_process_plain(struct fetch_file_context *ctx,
{
#ifdef HAVE_MMAP
fetch_msg msg;
- char *buf;
+ char *buf = NULL;
size_t buf_size;
int fd; /**< The file descriptor of the object */
@@ -279,17 +279,17 @@ static void fetch_file_process_plain(struct fetch_file_context
*ctx,
/* set buffer size */
buf_size = fdstat->st_size;
- if (buf_size > FETCH_FILE_MAX_BUF_SIZE)
- buf_size = FETCH_FILE_MAX_BUF_SIZE;
/* allocate the buffer storage */
- buf = mmap(NULL, buf_size, PROT_READ, MAP_SHARED, fd, 0);
- if (buf == MAP_FAILED) {
- msg.type = FETCH_ERROR;
- msg.data.error = "Unable to map memory for file data buffer";
- fetch_file_send_callback(&msg, ctx);
- close(fd);
- return;
+ if (buf_size > 0) {
+ buf = mmap(NULL, buf_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (buf == MAP_FAILED) {
+ msg.type = FETCH_ERROR;
+ msg.data.error = "Unable to map memory for file data buffer";
+ fetch_file_send_callback(&msg, ctx);
+ close(fd);
+ return;
+ }
}
/* fetch is going to be successful */
@@ -327,7 +327,8 @@ static void fetch_file_process_plain(struct fetch_file_context *ctx,
fetch_file_process_aborted:
- munmap(buf, buf_size);
+ if (buf != NULL)
+ munmap(buf, buf_size);
close(fd);
#else
fetch_msg msg;
--
NetSurf Browser