]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove isc_string_copy, isc_string_copy_truncate and isc_string_append.
authorOndřej Surý <ondrej@sury.org>
Wed, 21 Mar 2018 16:20:59 +0000 (16:20 +0000)
committerOndřej Surý <ondrej@sury.org>
Thu, 12 Apr 2018 08:37:33 +0000 (10:37 +0200)
Use strlcpy and strlcat as appropriate instead.

lib/isc/include/isc/string.h
lib/isc/string.c
lib/isc/win32/libisc.def.in
lib/samples/nsprobe.c

index 0c77f87b37f8e24cf10a4e96d8ff7debcb586429..16987ef750faab820c0f6774720244a475f336d9 100644 (file)
 
 ISC_LANG_BEGINDECLS
 
-isc_result_t
-isc_string_copy(char *target, size_t size, const char *source);
-/*
- * Copy the string pointed to by 'source' to 'target' which is a
- * pointer to a string of at least 'size' bytes.
- *
- * Requires:
- *     'target' is a pointer to a char[] of at least 'size' bytes.
- *     'size' an integer > 0.
- *     'source' == NULL or points to a NUL terminated string.
- *
- * Ensures:
- *     If result == ISC_R_SUCCESS
- *             'target' will be a NUL terminated string of no more
- *             than 'size' bytes (including NUL).
- *
- *     If result == ISC_R_NOSPACE
- *             'target' is undefined.
- *
- * Returns:
- *     ISC_R_SUCCESS  -- 'source' was successfully copied to 'target'.
- *     ISC_R_NOSPACE  -- 'source' could not be copied since 'target'
- *                       is too small.
- */
-
-void
-isc_string_copy_truncate(char *target, size_t size, const char *source);
-/*
- * Copy the string pointed to by 'source' to 'target' which is a
- * pointer to a string of at least 'size' bytes.
- *
- * Requires:
- *     'target' is a pointer to a char[] of at least 'size' bytes.
- *     'size' an integer > 0.
- *     'source' == NULL or points to a NUL terminated string.
- *
- * Ensures:
- *     'target' will be a NUL terminated string of no more
- *     than 'size' bytes (including NUL).
- */
-
-isc_result_t
-isc_string_append(char *target, size_t size, const char *source);
-/*
- * Append the string pointed to by 'source' to 'target' which is a
- * pointer to a NUL terminated string of at least 'size' bytes.
- *
- * Requires:
- *     'target' is a pointer to a NUL terminated char[] of at
- *     least 'size' bytes.
- *     'size' an integer > 0.
- *     'source' == NULL or points to a NUL terminated string.
- *
- * Ensures:
- *     If result == ISC_R_SUCCESS
- *             'target' will be a NUL terminated string of no more
- *             than 'size' bytes (including NUL).
- *
- *     If result == ISC_R_NOSPACE
- *             'target' is undefined.
- *
- * Returns:
- *     ISC_R_SUCCESS  -- 'source' was successfully appended to 'target'.
- *     ISC_R_NOSPACE  -- 'source' could not be appended since 'target'
- *                       is too small.
- */
-
 isc_result_t
 isc_string_printf(char *target, size_t size, const char *format, ...)
        ISC_FORMAT_PRINTF(3, 4);
index a9e5d40aa6489d79ab57109d3f499e72cd106bb2..5701f1471e345da22e6cc6e909ed4a20fd295777 100644 (file)
 #include <isc/string.h>
 #include <isc/util.h>
 
-isc_result_t
-isc_string_copy(char *target, size_t size, const char *source) {
-       REQUIRE(size > 0U);
-
-       if (strlcpy(target, source, size) >= size) {
-               memset(target, ISC_STRING_MAGIC, size);
-               return (ISC_R_NOSPACE);
-       }
-
-       ENSURE(strlen(target) < size);
-
-       return (ISC_R_SUCCESS);
-}
-
-void
-isc_string_copy_truncate(char *target, size_t size, const char *source) {
-       REQUIRE(size > 0U);
-
-       strlcpy(target, source, size);
-
-       ENSURE(strlen(target) < size);
-}
-
-isc_result_t
-isc_string_append(char *target, size_t size, const char *source) {
-       REQUIRE(size > 0U);
-       REQUIRE(strlen(target) < size);
-
-       if (strlcat(target, source, size) >= size) {
-               memset(target, ISC_STRING_MAGIC, size);
-               return (ISC_R_NOSPACE);
-       }
-
-       ENSURE(strlen(target) < size);
-
-       return (ISC_R_SUCCESS);
-}
-
 isc_result_t
 isc_string_printf(char *target, size_t size, const char *format, ...) {
        va_list args;
index 85beac7e69597f5ededf79a89561fb4f60e7ceed..ee08d90b4289fa70e70dba0d02d52e7b03656e26 100644 (file)
@@ -645,9 +645,6 @@ isc_stdio_sync
 isc_stdio_tell
 isc_stdio_write
 isc_stdtime_get
-isc_string_append
-isc_string_copy
-isc_string_copy_truncate
 isc_string_printf
 isc_string_printf_truncate
 isc_string_regiondup
index 6830c2f615361fd13baeb08c4c67a7a42a3af098..46088cd8dc279dc36b6fed6102cb737f913c60ce 100644 (file)
@@ -467,17 +467,18 @@ set_nextqname(struct probe_trans *trans) {
        isc_buffer_t b;
        char buf[4096]; /* XXX ad-hoc constant, but should be enough */
 
-       if (*trans->qlabel == NULL)
+       if (*trans->qlabel == NULL) {
                return (ISC_R_NOMORE);
+       }
 
-       result = isc_string_copy(buf, sizeof(buf), *trans->qlabel);
-       if (result != ISC_R_SUCCESS)
-               return (result);
-       result = isc_string_append(buf, sizeof(buf), trans->domain);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       if (strlcpy(buf, *trans->qlabel, sizeof(buf)) >= sizeof(buf)) {
+               return ISC_R_NOSPACE;
+       }
 
-       domainlen = strlen(buf);
+       if ((domainlen = strlcat(buf, trans->domain, sizeof(buf))) >= sizeof(buf)) {
+               return ISC_R_NOSPACE;
+       }
+       
        isc_buffer_init(&b, buf, domainlen);
        isc_buffer_add(&b, domainlen);
        trans->qname = dns_fixedname_initname(&trans->fixedname);