[multiple] store srv->tmp_buf in tb var
rather than using srv->tmp_buf directly in code modifying temp buf (tb)personal/stbuehler/ci-build
parent
3e8cdb2e54
commit
ca97505a72
|
@ -206,6 +206,7 @@ void config_reset_config(connection * const con) {
|
|||
}
|
||||
|
||||
static int config_burl_normalize_cond (server *srv) {
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
|
||||
data_config * const config =(data_config *)srv->config_context->data[i];
|
||||
if (COMP_HTTP_QUERY_STRING != config->comp) continue;
|
||||
|
@ -214,11 +215,11 @@ static int config_burl_normalize_cond (server *srv) {
|
|||
case CONFIG_COND_EQ:
|
||||
/* (can use this routine as long as it does not perform
|
||||
* any regex-specific normalization of first arg) */
|
||||
pcre_keyvalue_burl_normalize_key(&config->string, srv->tmp_buf);
|
||||
pcre_keyvalue_burl_normalize_key(&config->string, tb);
|
||||
break;
|
||||
case CONFIG_COND_NOMATCH:
|
||||
case CONFIG_COND_MATCH:
|
||||
pcre_keyvalue_burl_normalize_key(&config->string, srv->tmp_buf);
|
||||
pcre_keyvalue_burl_normalize_key(&config->string, tb);
|
||||
if (!data_config_pcre_compile(config)) return 0;
|
||||
break;
|
||||
default:
|
||||
|
@ -237,9 +238,10 @@ static void config_warn_authn_module (server *srv, const char *module, size_t le
|
|||
if (NULL != du && du->type == TYPE_STRING) {
|
||||
data_string *ds = (data_string *)du;
|
||||
if (buffer_is_equal_string(&ds->value, module, len)) {
|
||||
buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("mod_authn_"));
|
||||
buffer_append_string_len(srv->tmp_buf, module, len);
|
||||
array_insert_value(srv->srvconf.modules, CONST_BUF_LEN(srv->tmp_buf));
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
buffer_copy_string_len(tb, CONST_STR_LEN("mod_authn_"));
|
||||
buffer_append_string_len(tb, module, len);
|
||||
array_insert_value(srv->srvconf.modules, CONST_BUF_LEN(tb));
|
||||
log_error(srv->errh, __FILE__, __LINE__,
|
||||
"Warning: please add \"mod_authn_%s\" to server.modules list "
|
||||
"in lighttpd.conf. A future release of lighttpd 1.4.x will "
|
||||
|
@ -1786,33 +1788,34 @@ int config_set_defaults(server *srv) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
buffer_copy_buffer(srv->tmp_buf, s->document_root);
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
buffer_copy_buffer(tb, s->document_root);
|
||||
|
||||
buffer_to_lower(srv->tmp_buf);
|
||||
buffer_to_lower(tb);
|
||||
|
||||
if (2 == s->force_lowercase_filenames) { /* user didn't configure it in global section? */
|
||||
s->force_lowercase_filenames = 0; /* default to 0 */
|
||||
|
||||
if (0 == stat(srv->tmp_buf->ptr, &st1)) {
|
||||
if (0 == stat(tb->ptr, &st1)) {
|
||||
int is_lower = 0;
|
||||
|
||||
is_lower = buffer_is_equal(srv->tmp_buf, s->document_root);
|
||||
is_lower = buffer_is_equal(tb, s->document_root);
|
||||
|
||||
/* lower-case existed, check upper-case */
|
||||
buffer_copy_buffer(srv->tmp_buf, s->document_root);
|
||||
buffer_copy_buffer(tb, s->document_root);
|
||||
|
||||
buffer_to_upper(srv->tmp_buf);
|
||||
buffer_to_upper(tb);
|
||||
|
||||
/* we have to handle the special case that upper and lower-casing results in the same filename
|
||||
* as in server.document-root = "/" or "/12345/" */
|
||||
|
||||
if (is_lower && buffer_is_equal(srv->tmp_buf, s->document_root)) {
|
||||
if (is_lower && buffer_is_equal(tb, s->document_root)) {
|
||||
/* lower-casing and upper-casing didn't result in
|
||||
* an other filename, no need to stat(),
|
||||
* just assume it is case-sensitive. */
|
||||
|
||||
s->force_lowercase_filenames = 0;
|
||||
} else if (0 == stat(srv->tmp_buf->ptr, &st2)) {
|
||||
} else if (0 == stat(tb->ptr, &st2)) {
|
||||
|
||||
/* upper case exists too, doesn't the FS handle this ? */
|
||||
|
||||
|
|
|
@ -139,7 +139,8 @@ static void mod_authn_add_scheme (server *srv, buffer *host)
|
|||
"ldap://", "ldaps://", "ldapi://", "cldap://"
|
||||
};
|
||||
char *b, *e = host->ptr;
|
||||
buffer_clear(srv->tmp_buf);
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
buffer_clear(tb);
|
||||
while (*(b = e)) {
|
||||
unsigned int j;
|
||||
while (*b==' '||*b=='\t'||*b=='\r'||*b=='\n'||*b==',') ++b;
|
||||
|
@ -147,19 +148,18 @@ static void mod_authn_add_scheme (server *srv, buffer *host)
|
|||
e = b;
|
||||
while (*e!=' '&&*e!='\t'&&*e!='\r'&&*e!='\n'&&*e!=','&&*e!='\0')
|
||||
++e;
|
||||
if (!buffer_string_is_empty(srv->tmp_buf))
|
||||
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(","));
|
||||
if (!buffer_string_is_empty(tb))
|
||||
buffer_append_string_len(tb, CONST_STR_LEN(","));
|
||||
for (j = 0; j < sizeof(schemes)/sizeof(char *); ++j) {
|
||||
if (buffer_eq_icase_ssn(b, schemes[j], strlen(schemes[j]))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == sizeof(schemes)/sizeof(char *))
|
||||
buffer_append_string_len(srv->tmp_buf,
|
||||
CONST_STR_LEN("ldap://"));
|
||||
buffer_append_string_len(srv->tmp_buf, b, (size_t)(e - b));
|
||||
buffer_append_string_len(tb, CONST_STR_LEN("ldap://"));
|
||||
buffer_append_string_len(tb, b, (size_t)(e - b));
|
||||
}
|
||||
buffer_copy_buffer(host, srv->tmp_buf);
|
||||
buffer_copy_buffer(host, tb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2210,7 +2210,7 @@ CONNECTION_FUNC(mod_openssl_handle_con_close)
|
|||
static void
|
||||
https_add_ssl_client_entries (connection *con, handler_ctx *hctx)
|
||||
{
|
||||
server *srv = con->srv;
|
||||
buffer * const tb = con->srv->tmp_buf;
|
||||
X509 *xs;
|
||||
X509_NAME *xn;
|
||||
int i, nentries;
|
||||
|
@ -2219,11 +2219,11 @@ https_add_ssl_client_entries (connection *con, handler_ctx *hctx)
|
|||
if (vr != X509_V_OK) {
|
||||
char errstr[256];
|
||||
ERR_error_string_n(vr, errstr, sizeof(errstr));
|
||||
buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("FAILED:"));
|
||||
buffer_append_string(srv->tmp_buf, errstr);
|
||||
buffer_copy_string_len(tb, CONST_STR_LEN("FAILED:"));
|
||||
buffer_append_string(tb, errstr);
|
||||
http_header_env_set(con,
|
||||
CONST_STR_LEN("SSL_CLIENT_VERIFY"),
|
||||
CONST_BUF_LEN(srv->tmp_buf));
|
||||
CONST_BUF_LEN(tb));
|
||||
return;
|
||||
} else if (!(xs = SSL_get_peer_certificate(hctx->ssl))) {
|
||||
http_header_env_set(con,
|
||||
|
@ -2247,7 +2247,7 @@ https_add_ssl_client_entries (connection *con, handler_ctx *hctx)
|
|||
buf, (size_t)len);
|
||||
}
|
||||
}
|
||||
buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("SSL_CLIENT_S_DN_"));
|
||||
buffer_copy_string_len(tb, CONST_STR_LEN("SSL_CLIENT_S_DN_"));
|
||||
for (i = 0, nentries = X509_NAME_entry_count(xn); i < nentries; ++i) {
|
||||
int xobjnid;
|
||||
const char * xobjsn;
|
||||
|
@ -2259,10 +2259,10 @@ https_add_ssl_client_entries (connection *con, handler_ctx *hctx)
|
|||
xobjnid = OBJ_obj2nid((ASN1_OBJECT*)X509_NAME_ENTRY_get_object(xe));
|
||||
xobjsn = OBJ_nid2sn(xobjnid);
|
||||
if (xobjsn) {
|
||||
buffer_string_set_length(srv->tmp_buf,sizeof("SSL_CLIENT_S_DN_")-1);
|
||||
buffer_append_string(srv->tmp_buf, xobjsn);
|
||||
buffer_string_set_length(tb, sizeof("SSL_CLIENT_S_DN_")-1);
|
||||
buffer_append_string(tb, xobjsn);
|
||||
http_header_env_set(con,
|
||||
CONST_BUF_LEN(srv->tmp_buf),
|
||||
CONST_BUF_LEN(tb),
|
||||
(const char*)X509_NAME_ENTRY_get_data(xe)->data,
|
||||
X509_NAME_ENTRY_get_data(xe)->length);
|
||||
}
|
||||
|
@ -2300,19 +2300,16 @@ https_add_ssl_client_entries (connection *con, handler_ctx *hctx)
|
|||
if (hctx->conf.ssl_verifyclient_export_cert) {
|
||||
BIO *bio;
|
||||
if (NULL != (bio = BIO_new(BIO_s_mem()))) {
|
||||
buffer *cert = srv->tmp_buf;
|
||||
int n;
|
||||
|
||||
PEM_write_bio_X509(bio, xs);
|
||||
n = BIO_pending(bio);
|
||||
const int n = BIO_pending(bio);
|
||||
|
||||
buffer_string_prepare_copy(cert, n);
|
||||
BIO_read(bio, cert->ptr, n);
|
||||
buffer_string_prepare_copy(tb, n);
|
||||
BIO_read(bio, tb->ptr, n);
|
||||
BIO_free(bio);
|
||||
buffer_commit(cert, n);
|
||||
buffer_commit(tb, n);
|
||||
http_header_env_set(con,
|
||||
CONST_STR_LEN("SSL_CLIENT_CERT"),
|
||||
CONST_BUF_LEN(cert));
|
||||
CONST_BUF_LEN(tb));
|
||||
}
|
||||
}
|
||||
X509_free(xs);
|
||||
|
|
|
@ -78,11 +78,12 @@ static pcre_keyvalue_buffer * mod_redirect_parse_list(server *srv, const array *
|
|||
pcre_keyvalue_buffer * const redirect = pcre_keyvalue_buffer_init();
|
||||
redirect->x0 = (unsigned short)condidx;
|
||||
log_error_st * const errh = srv->errh;
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
for (uint32_t j = 0; j < a->used; ++j) {
|
||||
data_string *ds = (data_string *)a->data[j];
|
||||
if (srv->srvconf.http_url_normalize) {
|
||||
pcre_keyvalue_burl_normalize_key(&ds->key, srv->tmp_buf);
|
||||
pcre_keyvalue_burl_normalize_value(&ds->value, srv->tmp_buf);
|
||||
pcre_keyvalue_burl_normalize_key(&ds->key, tb);
|
||||
pcre_keyvalue_burl_normalize_value(&ds->value, tb);
|
||||
}
|
||||
if (!pcre_keyvalue_buffer_append(errh, redirect, &ds->key, &ds->value)){
|
||||
log_error(errh, __FILE__, __LINE__,
|
||||
|
|
|
@ -100,11 +100,12 @@ static pcre_keyvalue_buffer * mod_rewrite_parse_list(server *srv, const array *a
|
|||
kvb->x0 = (unsigned short)condidx;
|
||||
}
|
||||
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
for (uint32_t j = 0; j < a->used; ++j) {
|
||||
data_string *ds = (data_string *)a->data[j];
|
||||
if (srv->srvconf.http_url_normalize) {
|
||||
pcre_keyvalue_burl_normalize_key(&ds->key, srv->tmp_buf);
|
||||
pcre_keyvalue_burl_normalize_value(&ds->value, srv->tmp_buf);
|
||||
pcre_keyvalue_burl_normalize_key(&ds->key, tb);
|
||||
pcre_keyvalue_burl_normalize_value(&ds->value, tb);
|
||||
}
|
||||
if (!pcre_keyvalue_buffer_append(srv->errh, kvb, &ds->key, &ds->value)){
|
||||
log_error(srv->errh, __FILE__, __LINE__,
|
||||
|
|
|
@ -55,7 +55,8 @@ static void mod_vhostdb_dbconf_add_scheme (server *srv, buffer *host)
|
|||
"ldap://", "ldaps://", "ldapi://", "cldap://"
|
||||
};
|
||||
char *b, *e = host->ptr;
|
||||
buffer_clear(srv->tmp_buf);
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
buffer_clear(tb);
|
||||
while (*(b = e)) {
|
||||
unsigned int j;
|
||||
while (*b==' '||*b=='\t'||*b=='\r'||*b=='\n'||*b==',') ++b;
|
||||
|
@ -63,19 +64,18 @@ static void mod_vhostdb_dbconf_add_scheme (server *srv, buffer *host)
|
|||
e = b;
|
||||
while (*e!=' '&&*e!='\t'&&*e!='\r'&&*e!='\n'&&*e!=','&&*e!='\0')
|
||||
++e;
|
||||
if (!buffer_string_is_empty(srv->tmp_buf))
|
||||
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(","));
|
||||
if (!buffer_string_is_empty(tb))
|
||||
buffer_append_string_len(tb, CONST_STR_LEN(","));
|
||||
for (j = 0; j < sizeof(schemes)/sizeof(char *); ++j) {
|
||||
if (buffer_eq_icase_ssn(b, schemes[j], strlen(schemes[j]))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == sizeof(schemes)/sizeof(char *))
|
||||
buffer_append_string_len(srv->tmp_buf,
|
||||
CONST_STR_LEN("ldap://"));
|
||||
buffer_append_string_len(srv->tmp_buf, b, (size_t)(e - b));
|
||||
buffer_append_string_len(tb, CONST_STR_LEN("ldap://"));
|
||||
buffer_append_string_len(tb, b, (size_t)(e - b));
|
||||
}
|
||||
buffer_copy_buffer(host, srv->tmp_buf);
|
||||
buffer_copy_buffer(host, tb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,15 +98,16 @@ static int network_host_parse_addr(server *srv, sock_addr *addr, socklen_t *addr
|
|||
return -1;
|
||||
#endif
|
||||
}
|
||||
buffer_copy_buffer(srv->tmp_buf, host);
|
||||
h = srv->tmp_buf->ptr;
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
buffer_copy_buffer(tb, host);
|
||||
h = tb->ptr;
|
||||
if (h[0] == '[') {
|
||||
family = AF_INET6;
|
||||
if ((h = strchr(h, ']'))) {
|
||||
*h++ = '\0';
|
||||
if (*h == ':') colon = h;
|
||||
} /*(else should not happen; validated in configparser.y)*/
|
||||
h = srv->tmp_buf->ptr+1;
|
||||
h = tb->ptr+1;
|
||||
}
|
||||
else {
|
||||
colon = strrchr(h, ':');
|
||||
|
|
33
src/plugin.c
33
src/plugin.c
|
@ -161,6 +161,7 @@ int plugins_load(server *srv) {
|
|||
}
|
||||
#else /* defined(LIGHTTPD_STATIC) */
|
||||
int plugins_load(server *srv) {
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
plugin *p;
|
||||
int (*init)(plugin *pl);
|
||||
size_t i, j;
|
||||
|
@ -179,19 +180,19 @@ int plugins_load(server *srv) {
|
|||
}
|
||||
}
|
||||
|
||||
buffer_copy_buffer(srv->tmp_buf, srv->srvconf.modules_dir);
|
||||
buffer_copy_buffer(tb, srv->srvconf.modules_dir);
|
||||
|
||||
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("/"));
|
||||
buffer_append_string(srv->tmp_buf, module);
|
||||
buffer_append_string_len(tb, CONST_STR_LEN("/"));
|
||||
buffer_append_string(tb, module);
|
||||
#if defined(__WIN32) || defined(__CYGWIN__)
|
||||
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(".dll"));
|
||||
buffer_append_string_len(tb, CONST_STR_LEN(".dll"));
|
||||
#else
|
||||
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(".so"));
|
||||
buffer_append_string_len(tb, CONST_STR_LEN(".so"));
|
||||
#endif
|
||||
|
||||
p = plugin_init();
|
||||
#ifdef __WIN32
|
||||
if (NULL == (p->lib = LoadLibrary(srv->tmp_buf->ptr))) {
|
||||
if (NULL == (p->lib = LoadLibrary(tb->ptr))) {
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
|
@ -203,7 +204,7 @@ int plugins_load(server *srv) {
|
|||
0, NULL);
|
||||
|
||||
log_error(srv->errh, __FILE__, __LINE__,
|
||||
"LoadLibrary() failed %s %s", lpMsgBuf, srv->tmp_buf->ptr);
|
||||
"LoadLibrary() failed %s %s", lpMsgBuf, tb->ptr);
|
||||
|
||||
plugin_free(p);
|
||||
|
||||
|
@ -211,9 +212,9 @@ int plugins_load(server *srv) {
|
|||
|
||||
}
|
||||
#else
|
||||
if (NULL == (p->lib = dlopen(srv->tmp_buf->ptr, RTLD_NOW|RTLD_GLOBAL))) {
|
||||
if (NULL == (p->lib = dlopen(tb->ptr, RTLD_NOW|RTLD_GLOBAL))) {
|
||||
log_error(srv->errh, __FILE__, __LINE__,
|
||||
"dlopen() failed for: %s %s", srv->tmp_buf->ptr, dlerror());
|
||||
"dlopen() failed for: %s %s", tb->ptr, dlerror());
|
||||
|
||||
plugin_free(p);
|
||||
|
||||
|
@ -221,11 +222,11 @@ int plugins_load(server *srv) {
|
|||
}
|
||||
|
||||
#endif
|
||||
buffer_copy_string(srv->tmp_buf, module);
|
||||
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("_plugin_init"));
|
||||
buffer_copy_string(tb, module);
|
||||
buffer_append_string_len(tb, CONST_STR_LEN("_plugin_init"));
|
||||
|
||||
#ifdef __WIN32
|
||||
init = GetProcAddress(p->lib, srv->tmp_buf->ptr);
|
||||
init = GetProcAddress(p->lib, tb->ptr);
|
||||
|
||||
if (init == NULL) {
|
||||
LPVOID lpMsgBuf;
|
||||
|
@ -239,7 +240,7 @@ int plugins_load(server *srv) {
|
|||
0, NULL);
|
||||
|
||||
log_error(srv->errh, __FILE__, __LINE__,
|
||||
"getprocaddress failed: %s %s", srv->tmp_buf->ptr, lpMsgBuf);
|
||||
"getprocaddress failed: %s %s", tb->ptr, lpMsgBuf);
|
||||
|
||||
plugin_free(p);
|
||||
return -1;
|
||||
|
@ -247,16 +248,16 @@ int plugins_load(server *srv) {
|
|||
|
||||
#else
|
||||
#if 1
|
||||
init = (int (*)(plugin *))(intptr_t)dlsym(p->lib, srv->tmp_buf->ptr);
|
||||
init = (int (*)(plugin *))(intptr_t)dlsym(p->lib, tb->ptr);
|
||||
#else
|
||||
*(void **)(&init) = dlsym(p->lib, srv->tmp_buf->ptr);
|
||||
*(void **)(&init) = dlsym(p->lib, tb->ptr);
|
||||
#endif
|
||||
if (NULL == init) {
|
||||
const char *error = dlerror();
|
||||
if (error != NULL) {
|
||||
log_error(srv->errh, __FILE__, __LINE__, "dlsym: %s", error);
|
||||
} else {
|
||||
log_error(srv->errh, __FILE__, __LINE__, "dlsym symbol not found: %s", srv->tmp_buf->ptr);
|
||||
log_error(srv->errh, __FILE__, __LINE__, "dlsym symbol not found: %s", tb->ptr);
|
||||
}
|
||||
|
||||
plugin_free(p);
|
||||
|
|
|
@ -1330,9 +1330,10 @@ static int server_main (server * const srv, int argc, char **argv) {
|
|||
|
||||
/* write pid file */
|
||||
if (pid_fd > 2) {
|
||||
buffer_copy_int(srv->tmp_buf, srv->pid);
|
||||
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("\n"));
|
||||
if (-1 == write_all(pid_fd, CONST_BUF_LEN(srv->tmp_buf))) {
|
||||
buffer * const tb = srv->tmp_buf;
|
||||
buffer_copy_int(tb, srv->pid);
|
||||
buffer_append_string_len(tb, CONST_STR_LEN("\n"));
|
||||
if (-1 == write_all(pid_fd, CONST_BUF_LEN(tb))) {
|
||||
log_perror(srv->errh, __FILE__, __LINE__, "Couldn't write pid file");
|
||||
close(pid_fd);
|
||||
pid_fd = -1;
|
||||
|
|
Loading…
Reference in New Issue