[master] 233b132 Polish the heritage structure a little bit, and don't pass the panic_string to syslog until we have washed it.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Oct 21 09:36:42 CEST 2015
commit 233b1328a937b243b87dadc858e612990cf66018
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Oct 21 07:36:05 2015 +0000
Polish the heritage structure a little bit, and don't pass the
panic_string to syslog until we have washed it.
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index c51007b..5dd890e 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -623,7 +623,7 @@ VRT_r_server_identity(VRT_CTX)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- if (heritage.identity[0] != '\0')
+ if (heritage.identity != NULL)
return (heritage.identity);
else
return (heritage.name);
diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h
index 27c3a33..42e9ec7 100644
--- a/bin/varnishd/common/heritage.h
+++ b/bin/varnishd/common/heritage.h
@@ -56,7 +56,6 @@ struct heritage {
/* Sockets from which to accept connections */
struct listen_sock_head socks;
- unsigned nsocks;
/* Hash method */
const struct hash_slinger *hash;
@@ -66,7 +65,7 @@ struct heritage {
struct params *param;
char *name;
- char identity[1024];
+ const char *identity;
char *panic_str;
ssize_t panic_str_len;
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index 1d2a7a3..9308fa3 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -125,18 +125,17 @@ mgt_panic_record(pid_t r)
{
char time_str[30];
- AN(heritage.panic_str[0]);
- REPORT(LOG_ERR, "Child (%jd) Panic message:\n%s",
- (intmax_t)r, heritage.panic_str);
-
if (child_panic != NULL)
VSB_delete(child_panic);
child_panic = VSB_new_auto();
AN(child_panic);
VTIM_format(VTIM_real(), time_str);
- VSB_printf(child_panic, "Last panic at: %s\n", time_str);
- VSB_cat(child_panic, heritage.panic_str);
+ VSB_printf(child_panic, "Panic at: %s\n", time_str);
+ VSB_quote(child_panic, heritage.panic_str,
+ strnlen(heritage.panic_str, heritage.panic_str_len), 0);
AZ(VSB_finish(child_panic));
+ REPORT(LOG_ERR, "Child (%jd) %s",
+ (intmax_t)r, VSB_data(child_panic));
}
static void
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 5ceb80d..5dea3d4 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -424,9 +424,10 @@ identify(const char *i_arg)
strcpy(id, "varnishd");
if (i_arg != NULL) {
- if (strlen(i_arg) + 1 > sizeof heritage.identity)
- ARGV_ERR("Identity (-i) name too long.\n");
- strcpy(heritage.identity, i_arg);
+ if (strlen(i_arg) + 1 > 1024)
+ ARGV_ERR("Identity (-i) name too long (max 1023).\n");
+ heritage.identity = strdup(i_arg);
+ AN(heritage.identity);
i = strlen(id);
id[i++] = '/';
for (; i < (sizeof(id) - 1L); i++) {
More information about the varnish-commit
mailing list