From: Evan Hunt Date: Sat, 22 May 2021 00:17:23 +0000 (-0700) Subject: remove dns_name_copy() implementation X-Git-Tag: v9.17.14~33^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea7b28f101a840e14cfad2a03765435e2a9e7129;p=thirdparty%2Fbind9.git remove dns_name_copy() implementation Remove dns_name_copy() and refactor the underlying code since it will only be called by dns_name_copynf() now, and can't fail. --- diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 16bb5ffa33a..48c10bfaddf 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -1240,33 +1240,12 @@ dns_name_settotextfilter(dns_name_totextfilter_t *proc); * Includes space for the terminating NULL. */ -isc_result_t -dns_name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target); -/*%< - * Copies the name in 'source' into 'dest'. The name data is copied to - * the 'target' buffer, which is then set as the buffer for 'dest'. - * - * Requires: - * \li 'source' is a valid name. - * - * \li 'dest' is an initialized name. - * - * \li 'target' is an initialized buffer. - * - * Ensures: - * - *\li On success, the used space in target is updated. - * - * Returns: - *\li #ISC_R_SUCCESS - *\li #ISC_R_NOSPACE - */ - void dns_name_copynf(const dns_name_t *source, dns_name_t *dest); /*%< * Copies the name in 'source' into 'dest'. The name data is copied to - * the dedicated buffer for 'dest'. + * the dedicated buffer for 'dest'. (If copying to a name that doesn't + * have a dedicated buffer, use dns_name_setbuffer() first.) * * Requires: * \li 'source' is a valid name. diff --git a/lib/dns/name.c b/lib/dns/name.c index fd9a8ced3b7..e5715638d0e 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -2462,24 +2462,23 @@ dns_name_fromstring2(dns_name_t *target, const char *src, return (result); } -static isc_result_t -name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target) { +void +dns_name_copynf(const dns_name_t *source, dns_name_t *dest) { + isc_buffer_t *target = NULL; unsigned char *ndata = NULL; - /* - * Make dest a copy of source. - */ - + REQUIRE(VALID_NAME(source)); + REQUIRE(VALID_NAME(dest)); REQUIRE(BINDABLE(dest)); - /* - * Set up. - */ - if (target->length - target->used < source->length) { - return (ISC_R_NOSPACE); - } + target = dest->buffer; - ndata = (unsigned char *)target->base + target->used; + REQUIRE(target != NULL); + REQUIRE(target->length >= source->length); + + isc_buffer_clear(target); + + ndata = (unsigned char *)target->base; dest->ndata = target->base; if (source->length != 0) { @@ -2504,28 +2503,6 @@ name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target) { } isc_buffer_add(target, dest->length); - - return (ISC_R_SUCCESS); -} - -isc_result_t -dns_name_copy(const dns_name_t *source, dns_name_t *dest, - isc_buffer_t *target) { - REQUIRE(VALID_NAME(source)); - REQUIRE(VALID_NAME(dest)); - REQUIRE(target != NULL); - - return (name_copy(source, dest, target)); -} - -void -dns_name_copynf(const dns_name_t *source, dns_name_t *dest) { - REQUIRE(VALID_NAME(source)); - REQUIRE(VALID_NAME(dest)); - REQUIRE(dest->buffer != NULL); - - isc_buffer_clear(dest->buffer); - RUNTIME_CHECK(name_copy(source, dest, dest->buffer) == ISC_R_SUCCESS); } /* diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index feedfb94476..1eba5af96d3 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -576,7 +576,6 @@ dns_name_caseequal dns_name_clone dns_name_compare dns_name_concatenate -dns_name_copy dns_name_copynf dns_name_countlabels dns_name_digest