diff options
author | 2015-09-10 14:12:38 +0000 | |
---|---|---|
committer | 2015-09-10 14:12:38 +0000 | |
commit | 72628ec98b474e420b36d0cbb70b818f7fbae921 (patch) | |
tree | b357aa5db21676d0aebb690bae86308a02ad6723 | |
parent | Don't stop spoofing GPT partitions when the OpenBSD partition is (diff) | |
download | wireguard-openbsd-72628ec98b474e420b36d0cbb70b818f7fbae921.tar.xz wireguard-openbsd-72628ec98b474e420b36d0cbb70b818f7fbae921.zip |
Fix handling of compat/b64_{ntop,pton} by using __-prefixed versions directly,
similar to what ssh does. Otherwise they need resolv.h including, which causes
problems on OS with newer resolv.h/nameser.h headers which cause conflicts with
NSD's T_xxx resource record #defines. autoconf bits adapted from tmux portable.
ok florian@
-rw-r--r-- | usr.sbin/nsd/compat/b64_ntop.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/compat/b64_pton.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/configparser.y | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/configure.ac | 47 | ||||
-rw-r--r-- | usr.sbin/nsd/options.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/rdata.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/zonec.c | 2 |
7 files changed, 45 insertions, 14 deletions
diff --git a/usr.sbin/nsd/compat/b64_ntop.c b/usr.sbin/nsd/compat/b64_ntop.c index 2523537072d..748a40be4b1 100644 --- a/usr.sbin/nsd/compat/b64_ntop.c +++ b/usr.sbin/nsd/compat/b64_ntop.c @@ -123,7 +123,7 @@ static const char Pad64 = '='; */ int -b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) { +__b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) { size_t datalength = 0; uint8_t input[3]; uint8_t output[4]; diff --git a/usr.sbin/nsd/compat/b64_pton.c b/usr.sbin/nsd/compat/b64_pton.c index 86a6ebeff1d..a67d851d5d5 100644 --- a/usr.sbin/nsd/compat/b64_pton.c +++ b/usr.sbin/nsd/compat/b64_pton.c @@ -378,7 +378,7 @@ b64_pton_len(unsigned char const *src) int -b64_pton(char const *src, uint8_t *target, size_t targsize) +__b64_pton(char const *src, uint8_t *target, size_t targsize) { if (!b64rmap_initialized) b64_initialize_rmap (); diff --git a/usr.sbin/nsd/configparser.y b/usr.sbin/nsd/configparser.y index 259c82a92ef..6c55bac5195 100644 --- a/usr.sbin/nsd/configparser.y +++ b/usr.sbin/nsd/configparser.y @@ -828,7 +828,7 @@ key_secret: VAR_SECRET STRING assert(cfg_parser->current_key); #endif cfg_parser->current_key->secret = region_strdup(cfg_parser->opt->region, $2); - size = b64_pton($2, data, sizeof(data)); + size = __b64_pton($2, data, sizeof(data)); if(size == -1) { c_error_msg("Cannot base64 decode tsig secret %s", cfg_parser->current_key->name? diff --git a/usr.sbin/nsd/configure.ac b/usr.sbin/nsd/configure.ac index fcbf40b075c..60ea50d2bf2 100644 --- a/usr.sbin/nsd/configure.ac +++ b/usr.sbin/nsd/configure.ac @@ -654,12 +654,45 @@ AC_REPLACE_FUNCS(snprintf) AC_REPLACE_FUNCS(strlcat) AC_REPLACE_FUNCS(strlcpy) AC_REPLACE_FUNCS(strptime) -AC_REPLACE_FUNCS(b64_pton) -AC_REPLACE_FUNCS(b64_ntop) AC_REPLACE_FUNCS(pselect) AC_REPLACE_FUNCS(memmove) AC_REPLACE_FUNCS(reallocarray) +# +# Check for b64_ntop (and assume result applies to b64_pton as well). +# The functions are actually prefixed with __ and resolv.h defines +# macros for the unprefixed versions, however including this header +# causes conflicts with our T_xx defines. +# +AC_MSG_CHECKING(for __b64_ntop) +AC_TRY_LINK([#include <stddef.h>], + [__b64_ntop(NULL, 0, NULL, 0);], + found_b64_ntop=yes, + found_b64_ntop=no +) +if test "x$found_b64_ntop" = xno; then + AC_MSG_RESULT(no) + + AC_MSG_CHECKING(for __b64_ntop with -lresolv) + LIBS="$LIBS -lresolv" + AC_TRY_LINK([#include <stddef.h>], + [__b64_ntop(NULL, 0, NULL, 0);], + found_b64_ntop=yes, + found_b64_ntop=no + ) + if test "x$found_b64_ntop" = xno; then + AC_MSG_RESULT(no) + fi +fi +if test "x$found_b64_ntop" = xyes; then + AC_DEFINE(HAVE_B64_NTOP) + AC_DEFINE(HAVE_B64_PTON) + AC_MSG_RESULT(yes) +else + AC_LIBOBJ([b64_ntop]) + AC_LIBOBJ([b64_pton]) +fi + AC_MSG_CHECKING(for pselect prototype in sys/select.h) AC_EGREP_HEADER([[^a-zA-Z_]*pselect[^a-zA-Z_]], sys/select.h, AC_DEFINE(HAVE_PSELECT_PROTO, 1, [if sys/select.h provides pselect prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) @@ -941,13 +974,11 @@ AH_BOTTOM([ ]) AH_BOTTOM([ -#ifndef HAVE_B64_NTOP -int b64_ntop(uint8_t const *src, size_t srclength, +int __b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize); -#endif /* !HAVE_B64_NTOP */ -#ifndef HAVE_B64_PTON -int b64_pton(char const *src, uint8_t *target, size_t targsize); -#endif /* !HAVE_B64_PTON */ +int __b64_pton(char const *src, uint8_t *target, size_t targsize); +]) +AH_BOTTOM([ #ifndef HAVE_FSEEKO #define fseeko fseek #define ftello ftell diff --git a/usr.sbin/nsd/options.c b/usr.sbin/nsd/options.c index 8b8f3f5352e..cefb928ede8 100644 --- a/usr.sbin/nsd/options.c +++ b/usr.sbin/nsd/options.c @@ -1198,7 +1198,7 @@ key_options_setup(region_type* region, key_options_t* key) key->tsig_key->size = 0; key->tsig_key->data = NULL; } - size = b64_pton(key->secret, data, sizeof(data)); + size = __b64_pton(key->secret, data, sizeof(data)); if(size == -1) { log_msg(LOG_ERR, "Failed to parse tsig key data %s", key->name); diff --git a/usr.sbin/nsd/rdata.c b/usr.sbin/nsd/rdata.c index c7385c5e77e..0be90849511 100644 --- a/usr.sbin/nsd/rdata.c +++ b/usr.sbin/nsd/rdata.c @@ -397,7 +397,7 @@ rdata_base64_to_string(buffer_type *output, rdata_atom_type rdata, if(size == 0) return 1; buffer_reserve(output, size * 2 + 1); - length = b64_ntop(rdata_atom_data(rdata), size, + length = __b64_ntop(rdata_atom_data(rdata), size, (char *) buffer_current(output), size * 2); if (length > 0) { buffer_skip(output, length); diff --git a/usr.sbin/nsd/zonec.c b/usr.sbin/nsd/zonec.c index 49fa74417cc..0ff7f9cb705 100644 --- a/usr.sbin/nsd/zonec.c +++ b/usr.sbin/nsd/zonec.c @@ -639,7 +639,7 @@ zparser_conv_b64(region_type *region, const char *b64) uint16_t *r = NULL; int i; - i = b64_pton(b64, buffer, B64BUFSIZE); + i = __b64_pton(b64, buffer, B64BUFSIZE); if (i == -1) { zc_error_prev_line("invalid base64 data"); } else { |