From: florian Date: Wed, 2 Mar 2022 11:10:43 +0000 (+0000) Subject: Nothing uses kv_flags. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2253120044e27eb7d0edd9511dcf1f5675a0e47b;p=openbsd Nothing uses kv_flags. John (j AT bitminer.ca) pointed out that we didn't correctly initialize struct kv and might use slower KV_FLAG_GLOBBING path in kv_find depending on stack garbage. Instead of fixing the initialization just delete kv_flags from struct kv. OK claudio, tb --- diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c index 99687a18939..2acecd1732f 100644 --- a/usr.sbin/httpd/httpd.c +++ b/usr.sbin/httpd/httpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.c,v 1.71 2021/01/27 07:21:52 deraadt Exp $ */ +/* $OpenBSD: httpd.c,v 1.72 2022/03/02 11:10:43 florian Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -1063,22 +1063,7 @@ kv_free(struct kv *kv) struct kv * kv_find(struct kvtree *keys, struct kv *kv) { - struct kv *match; - const char *key; - - if (kv->kv_flags & KV_FLAG_GLOBBING) { - /* Test header key using shell globbing rules */ - key = kv->kv_key == NULL ? "" : kv->kv_key; - RB_FOREACH(match, kvtree, keys) { - if (fnmatch(key, match->kv_key, FNM_CASEFOLD) == 0) - break; - } - } else { - /* Fast tree-based lookup only works without globbing */ - match = RB_FIND(kvtree, keys, kv); - } - - return (match); + return (RB_FIND(kvtree, keys, kv)); } int diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 692c5611bb5..50ee022dc34 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.159 2022/02/27 20:30:30 bluhm Exp $ */ +/* $OpenBSD: httpd.h,v 1.160 2022/03/02 11:10:43 florian Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -131,10 +131,6 @@ struct kv { char *kv_key; char *kv_value; -#define KV_FLAG_INVALID 0x01 -#define KV_FLAG_GLOBBING 0x02 - uint8_t kv_flags; - struct kvlist kv_children; struct kv *kv_parent; TAILQ_ENTRY(kv) kv_entry; diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c index 6542b1f1739..381fade2924 100644 --- a/usr.sbin/httpd/server_fcgi.c +++ b/usr.sbin/httpd/server_fcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_fcgi.c,v 1.89 2021/10/23 15:52:44 benno Exp $ */ +/* $OpenBSD: server_fcgi.c,v 1.90 2022/03/02 11:10:43 florian Exp $ */ /* * Copyright (c) 2014 Florian Obser @@ -702,9 +702,6 @@ server_fcgi_writeheader(struct client *clt, struct kv *hdr, void *arg) const char *key; int ret; - if (hdr->kv_flags & KV_FLAG_INVALID) - return (0); - /* The key might have been updated in the parent */ if (hdr->kv_parent != NULL && hdr->kv_parent->kv_key != NULL) key = hdr->kv_parent->kv_key; diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index d5d31fa03ef..63c91e8d075 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.149 2021/11/11 15:52:33 claudio Exp $ */ +/* $OpenBSD: server_http.c,v 1.150 2022/03/02 11:10:43 florian Exp $ */ /* * Copyright (c) 2020 Matthias Pressfreund @@ -1647,9 +1647,6 @@ server_writeheader_http(struct client *clt, struct kv *hdr, void *arg) char *ptr; const char *key; - if (hdr->kv_flags & KV_FLAG_INVALID) - return (0); - /* The key might have been updated in the parent */ if (hdr->kv_parent != NULL && hdr->kv_parent->kv_key != NULL) key = hdr->kv_parent->kv_key;