From 3c73622f27c67eb636f19a938c5f401da8db901f Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 2 Feb 2022 13:51:22 -0500 Subject: hs: Double quote the metrics label value Fixes #40552 Signed-off-by: David Goulet --- src/feature/hs/hs_metrics.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/feature') diff --git a/src/feature/hs/hs_metrics.c b/src/feature/hs/hs_metrics.c index e6d3084f26..452bb44419 100644 --- a/src/feature/hs/hs_metrics.c +++ b/src/feature/hs/hs_metrics.c @@ -32,12 +32,16 @@ port_to_str(const uint16_t port) /** Return a static buffer pointer that contains a formatted label on the form * of key=value. * + * NOTE: Important, label values MUST NOT contain double quotes else, in the + * case of Prometheus, it will fail with a malformed line because we force the + * label value to be enclosed in double quotes. + * * Subsequent call to this function invalidates the previous buffer. */ static const char * format_label(const char *key, const char *value) { static char buf[128]; - tor_snprintf(buf, sizeof(buf), "%s=%s", key, value); + tor_snprintf(buf, sizeof(buf), "%s=\"%s\"", key, value); return buf; } -- cgit v1.2.3-54-g00ecf