diff options
author | Omar Polo <op@omarpolo.com> | 2024-06-08 18:37:57 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2024-06-08 18:37:57 +0000 |
commit | 401030113e383542ae85f2e51bde9f94ff4015f8 (patch) | |
tree | 2f21d5f5c19c85e2ce3efb50b7d3f6a0407c6336 | |
parent | fcf3f1fa9a0d6b30a189e7e71fc55348d72595ce (diff) |
change the approach for strnvis
instead of making things more obscure via gmid_strnvis(), let's
just check for strnvis with -Werror so we can swap the OS broken
implementation with the bundled OpenBSD one.
-rwxr-xr-x | configure | 17 | ||||
-rw-r--r-- | ge.c | 2 | ||||
-rw-r--r-- | gmid.c | 2 | ||||
-rw-r--r-- | gmid.h | 1 | ||||
-rw-r--r-- | have/Makefile | 3 | ||||
-rw-r--r-- | have/broken-strnvis.c | 15 | ||||
-rw-r--r-- | have/strnvis.c (renamed from have/vis.c) | 0 | ||||
-rw-r--r-- | utils.c | 16 |
8 files changed, 8 insertions, 48 deletions
@@ -275,7 +275,6 @@ fi HAVE_ENDIAN_H=0 HAVE_SYS_ENDIAN_H=0 HAVE_MACHINE_ENDIAN=0 -HAVE_BROKEN_STRNVIS=0 runtest endian_h ENDIAN_H || \ runtest sys_endian_h SYS_ENDIAN_H || \ @@ -316,12 +315,12 @@ runtest strtonum STRTONUM -D_OPENBSD_SOURCE || true runtest timingsafe_memcmp TIMINGSAFE_MEMCMP || true runtest tree_h TREE_H || true runtest vasprintf VASPRINTF -D_GNU_SOURCE || true -runtest vis VIS -DLIBBSD_OPENBSD_VIS || true -if [ ${HAVE_VIS} -eq 1 ]; then - if singletest broken-strnvis BROKEN_STRNVIS "-Wall -Werror"; then - HAVE_BROKEN_STRNVIS=1 - fi +# strnvis is a bit special since NetBSD, FreeBSD and MacOS have +# the broken version with the wrong semantics and arguments. +# Hence the -Wall -Werror check. +if ! singletest strnvis STRNVIS "-Wall -Werror"; then + CFLAGS="-I ${PWD}/compat/vis ${CFLAGS} ${CFLAGS}" fi if [ ${HAVE_ARC4RANDOM} -eq 1 -a ${HAVE_ARC4RANDOM_BUF} -eq 0 ]; then @@ -395,10 +394,6 @@ if [ ${HAVE_QUEUE_H} -eq 0 -o ${HAVE_IMSG} -eq 0 -o ${HAVE_TREE_H} -eq 0 ]; then CFLAGS="${CFLAGS} -I ${PWD}/compat" fi -if [ ${HAVE_VIS} -eq 0 ]; then - CFLAGS="${CFLAGS} -I ${PWD}/compat/vis" -fi - if [ $HAVE_LIBEVENT2 -eq 1 ]; then CFLAGS="$CFLAGS -DHAVE_LIBEVENT2=1" fi @@ -655,8 +650,6 @@ cat <<__HEREDOC__ # define HOST_NAME_MAX 255 # endif #endif - -#define HAVE_BROKEN_STRNVIS ${HAVE_BROKEN_STRNVIS} __HEREDOC__ echo "file config.h: written" 1>&2 @@ -83,7 +83,7 @@ log_request(struct client *c, int code, const char *meta) strlcpy(cntmp, subj + 4, sizeof(cntmp)); if ((n = strchr(cntmp, '/')) != NULL) *n = '\0'; - gmid_strnvis(cn, cntmp, sizeof(cn), VIS_WHITE|VIS_DQ); + strnvis(cn, cntmp, sizeof(cn), VIS_WHITE|VIS_DQ); } } @@ -140,7 +140,7 @@ log_request(struct client *c, int code, const char *meta) strlcpy(cntmp, subj + 4, sizeof(cntmp)); if ((n = strchr(cntmp, '/')) != NULL) *n = '\0'; - gmid_strnvis(cn, cntmp, sizeof(cn), VIS_WHITE|VIS_DQ); + strnvis(cn, cntmp, sizeof(cn), VIS_WHITE|VIS_DQ); } } @@ -469,6 +469,5 @@ EVP_PKEY *ssl_load_pkey(const uint8_t *, size_t); struct vhost *new_vhost(void); struct location *new_location(void); struct proxy *new_proxy(void); -int gmid_strnvis(char *, const char *, size_t, int); #endif diff --git a/have/Makefile b/have/Makefile index 1bdfc6b..bc9d7c5 100644 --- a/have/Makefile +++ b/have/Makefile @@ -7,7 +7,6 @@ DISTFILES = ASN1_time_parse.c \ X509_LOOKUP_mem.c \ arc4random.c \ arc4random_buf.c \ - broken-strnvis.c \ endian_h.c \ err.c \ explicit_bzero.c \ @@ -35,12 +34,12 @@ DISTFILES = ASN1_time_parse.c \ setresuid.c \ strlcat.c \ strlcpy.c \ + strnvis.c \ strtonum.c \ sys_endian_h.c \ timingsafe_memcmp.c \ tree_h.c \ vasprintf.c \ - vis.c \ wait_any.c all: diff --git a/have/broken-strnvis.c b/have/broken-strnvis.c deleted file mode 100644 index f2a9a59..0000000 --- a/have/broken-strnvis.c +++ /dev/null @@ -1,15 +0,0 @@ -/* - * public domain - */ - -#include <stdio.h> -#include <stdlib.h> -#include <vis.h> - -int -main(void) -{ - char buf[128]; - - return strnvis(buf, sizeof(buf), "Hello, world!\n", 0); -} diff --git a/have/vis.c b/have/strnvis.c index 85a4307..85a4307 100644 --- a/have/vis.c +++ b/have/strnvis.c @@ -497,19 +497,3 @@ new_proxy(void) p->protocols = TLS_PROTOCOLS_DEFAULT; return p; } - -/* - * I can't rant enough about this situation. As far as I've understood, - * OpenBSD introduced strnvis(3) with a signature, then NetBSD did it but - * with a incompatible signature. FreeBSD followed NetBSD. libbsd followed - * OpenBSD but now is thinking to switch. WTF? - */ -int -gmid_strnvis(char *dst, const char *src, size_t destsize, int flag) -{ -#if HAVE_BROKEN_STRNVIS - return strnvis(dst, destsize, src, flag); -#else - return strnvis(dst, src, destsize, flag); -#endif -} |