The output of server_root_strip() is a string. Use the correct format
authorbenno <benno@openbsd.org>
Sun, 25 Jul 2021 20:31:41 +0000 (20:31 +0000)
committerbenno <benno@openbsd.org>
Sun, 25 Jul 2021 20:31:41 +0000 (20:31 +0000)
"%s".  Same for the output of relay_expand_http().
with and ok claudio@
Found by Cedric Tessier, thanks!

usr.sbin/relayd/relay_http.c
usr.sbin/relayd/relayd.h

index 29e401e..b1cfafd 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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;
                }
 
index d83ec82..2236d14 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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 *);