From e472afa584518f34138a4b468b143edc71f62f87 Mon Sep 17 00:00:00 2001 From: benno Date: Sun, 25 Jul 2021 20:31:41 +0000 Subject: [PATCH] The output of server_root_strip() is a string. Use the correct format "%s". Same for the output of relay_expand_http(). with and ok claudio@ Found by Cedric Tessier, thanks! --- usr.sbin/relayd/relay_http.c | 6 +++--- usr.sbin/relayd/relayd.h | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/usr.sbin/relayd/relay_http.c b/usr.sbin/relayd/relay_http.c index 29e401e0935..b1cfafd9718 100644 --- a/usr.sbin/relayd/relay_http.c +++ b/usr.sbin/relayd/relay_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay_http.c,v 1.81 2021/03/24 20:59:54 benno Exp $ */ +/* $OpenBSD: relay_http.c,v 1.82 2021/07/25 20:31:41 benno Exp $ */ /* * Copyright (c) 2006 - 2016 Reyk Floeter @@ -1735,7 +1735,7 @@ relay_apply_actions(struct ctl_relay_event *cre, struct kvlist *actions, case KEY_OPTION_STRIP: nstrip = strtonum(kv->kv_value, 0, INT_MAX, NULL); if (kv->kv_type == KEY_TYPE_PATH) { - if (kv_setkey(match, + if (kv_setkey(match, "%s", server_root_strip(match->kv_key, nstrip)) == -1) goto fail; @@ -1763,7 +1763,7 @@ relay_apply_actions(struct ctl_relay_event *cre, struct kvlist *actions, if ((ptr = relay_expand_http(cre, kp->kv_value, buf, sizeof(buf))) == NULL) goto fail; - if (kv_set(match, ptr) == -1) + if (kv_set(match, "%s", ptr) == -1) goto fail; } diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index d83ec825aa2..2236d140f7e 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.267 2021/04/20 21:11:56 dv Exp $ */ +/* $OpenBSD: relayd.h,v 1.268 2021/07/25 20:31:41 benno Exp $ */ /* * Copyright (c) 2006 - 2016 Reyk Floeter @@ -1353,8 +1353,10 @@ u_int32_t prefixlen2mask(u_int8_t); int accept_reserve(int, struct sockaddr *, socklen_t *, int, volatile int *); struct kv *kv_add(struct kvtree *, char *, char *, int); -int kv_set(struct kv *, char *, ...); -int kv_setkey(struct kv *, char *, ...); +int kv_set(struct kv *, char *, ...) + __attribute__((__format__ (printf, 2, 3))); +int kv_setkey(struct kv *, char *, ...) + __attribute__((__format__ (printf, 2, 3))); void kv_delete(struct kvtree *, struct kv *); struct kv *kv_extend(struct kvtree *, struct kv *, char *); void kv_purge(struct kvtree *); -- 2.20.1