diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2018-11-23 00:37:38 -0500 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2018-11-23 00:37:38 -0500 |
commit | f69bd9cdb89f7288c982fafe550cc8f1297d08ca (patch) | |
tree | ea66c7a21cda103eb6b34c6672df8957a8c371c8 /src/mod_extforward.c | |
parent | 9749503b1dc221aed4ba6e215c6acb893d8281be (diff) | |
download | lighttpd-git-f69bd9cdb89f7288c982fafe550cc8f1297d08ca.tar.gz |
[core] perf: simple, quick buffer_clear()
quickly clear buffer instead of buffer_string_set_length(b, 0) or
buffer_reset(b). Avoids free() of large buffers about to be reused,
or buffers that are module-scoped, persistent, and reused.
(buffer_reset() should still be used with buffers in connection *con
when the data in the buffers is supplied by external, untrusted source)
Diffstat (limited to 'src/mod_extforward.c')
-rw-r--r-- | src/mod_extforward.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mod_extforward.c b/src/mod_extforward.c index ee9386b7..1493e16b 100644 --- a/src/mod_extforward.c +++ b/src/mod_extforward.c @@ -239,7 +239,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) { if (NULL != nm_slash) { log_error_write(srv, __FILE__, __LINE__, "sbsbs", "ERROR: untrusted CIDR masks are ignored (\"", ds->key, "\" => \"", ds->value, "\")"); } - buffer_reset(ds->value); /* empty is untrusted */ + buffer_clear(ds->value); /* empty is untrusted */ continue; } if (NULL != nm_slash) { @@ -266,7 +266,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) { rc = sock_addr_from_str_numeric(srv, &sm->addr, ds->key->ptr); *nm_slash = '/'; if (1 != rc) return HANDLER_ERROR; - buffer_reset(ds->value); /* empty is untrusted, e.g. if subnet (incorrectly) appears in X-Forwarded-For */ + buffer_clear(ds->value); /* empty is untrusted, e.g. if subnet (incorrectly) appears in X-Forwarded-For */ } } } @@ -964,7 +964,7 @@ static handler_t mod_extforward_Forwarded (server *srv, connection *con, plugin_ /* create X-Forwarded-For if not present * (and at least original connecting IP is a trusted proxy) */ buffer *xff = srv->tmp_buf; - buffer_string_set_length(xff, 0); + buffer_clear(xff); for (j = 0; j < used; ) { if (-1 == offsets[j]) { ++j; continue; } if (3 == offsets[j+1] |