ft_at
} ft_state;
-/*%
- * Note: If additional attributes are added that should not be set for
- * empty names, MAKE_EMPTY() must be changed so it clears them.
- */
-#define MAKE_EMPTY(name) \
- { \
- name->ndata = NULL; \
- name->length = 0; \
- name->attributes.absolute = false; \
- }
-
/*%
* Note that the name data must be a char array, not a string
* literal, to avoid compiler warnings about discarding
REQUIRE(DNS_NAME_BINDABLE(name));
- /*
- * Make 'name' empty in case of failure.
- */
- MAKE_EMPTY(name);
-
/*
* Set up the state machine.
*/
REQUIRE(DNS_NAME_VALID(source));
REQUIRE(DNS_NAME_VALID(name));
+
if (source == name) {
REQUIRE(!name->attributes.readonly);
isc_buffer_init(&buffer, source->ndata, source->length);
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) ||
(target == NULL && ISC_BUFFER_VALID(name->buffer)));
if (target == NULL) {
+ if (source->length > name->buffer->length) {
+ return ISC_R_NOSPACE;
+ }
target = name->buffer;
isc_buffer_clear(name->buffer);
+ } else if (source->length > target->length - target->used) {
+ return ISC_R_NOSPACE;
}
ndata = (unsigned char *)target->base + target->used;
name->ndata = ndata;
}
- if (source->length > (target->length - target->used)) {
- MAKE_EMPTY(name);
- return ISC_R_NOSPACE;
- }
-
/* label lengths are < 64 so tolower() does not affect them */
isc_ascii_lowercopy(ndata, source->ndata, source->length);
const uint32_t name_max = ISC_MIN(DNS_NAME_MAXWIRE,
isc_buffer_availablelength(target));
uint32_t name_len = 0;
- MAKE_EMPTY(name); /* in case of failure */
/*
* After chasing a compression pointer, these variables refer to the
length += suffix->length;
}
if (length > DNS_NAME_MAXWIRE) {
- MAKE_EMPTY(name);
return DNS_R_NAMETOOLONG;
}
if (length > nrem) {
- MAKE_EMPTY(name);
return ISC_R_NOSPACE;
}
REQUIRE(DNS_NAME_VALID(target));
REQUIRE(DNS_NAME_BINDABLE(target));
- /*
- * Make 'target' empty in case of failure.
- */
- MAKE_EMPTY(target);
-
target->ndata = isc_mem_get(mctx, source->length);
memmove(target->ndata, source->ndata, source->length);