summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2019-11-10 14:35:07 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2019-11-10 14:37:36 +0000
commitc14f01ea442295e2d658a1f9bec866c5638bb3ca (patch)
tree6f3fc8b7ec83a85ac9163d3f43047062cb9a0bf0 /content
parent8d652f1ff453a1d87dfdec9c6c8dd077a707c613 (diff)
downloadnetsurf-c14f01ea442295e2d658a1f9bec866c5638bb3ca.tar.gz
netsurf-c14f01ea442295e2d658a1f9bec866c5638bb3ca.tar.bz2
File fetcher: Optimise HTTP header generation.
Diffstat (limited to 'content')
-rw-r--r--content/fetchers/file.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index 5c9d15837..b5b4221dc 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -99,19 +99,21 @@ static bool fetch_file_send_header(struct fetch_file_context *ctx,
fetch_msg msg;
char header[64];
va_list ap;
+ int len;
va_start(ap, fmt);
-
- vsnprintf(header, sizeof header, fmt, ap);
-
+ len = vsnprintf(header, sizeof header, fmt, ap);
va_end(ap);
+ if (len >= (int)sizeof(header) || len < 0) {
+ return false;
+ }
+
msg.type = FETCH_HEADER;
msg.data.header_or_data.buf = (const uint8_t *) header;
- msg.data.header_or_data.len = strlen(header);
- fetch_file_send_callback(&msg, ctx);
+ msg.data.header_or_data.len = len;
- return ctx->aborted;
+ return fetch_file_send_callback(&msg, ctx);
}
/** callback to initialise the file fetcher. */