Distinct between suffix and suffixes more clearly

This commit is contained in:
Willem Toorop 2015-12-29 16:23:04 +01:00
parent ebe3d361ea
commit 54498cd556
2 changed files with 27 additions and 27 deletions

View File

@ -1006,8 +1006,8 @@ getdns_context_create_with_extended_memory_functions(
result->dns_root_servers = NULL; result->dns_root_servers = NULL;
result->root_servers_fn[0] = 0; result->root_servers_fn[0] = 0;
result->append_name = GETDNS_APPEND_NAME_ALWAYS; result->append_name = GETDNS_APPEND_NAME_ALWAYS;
result->suffix = no_suffixes; result->suffixes = no_suffixes;
result->suffix_len = sizeof(no_suffixes); result->suffixes_len = sizeof(no_suffixes);
gldns_buffer_init_frm_data(&gbuf, result->trust_anchors_spc gldns_buffer_init_frm_data(&gbuf, result->trust_anchors_spc
, sizeof(result->trust_anchors_spc)); , sizeof(result->trust_anchors_spc));
@ -1180,8 +1180,8 @@ getdns_context_destroy(struct getdns_context *context)
if (context->root_servers_fn[0]) if (context->root_servers_fn[0])
unlink(context->root_servers_fn); unlink(context->root_servers_fn);
if (context->suffix && context->suffix != no_suffixes) if (context->suffixes && context->suffixes != no_suffixes)
GETDNS_FREE(context->mf, context->suffix); GETDNS_FREE(context->mf, context->suffixes);
if (context->trust_anchors && if (context->trust_anchors &&
context->trust_anchors != context->trust_anchors_spc) context->trust_anchors != context->trust_anchors_spc)
@ -1818,8 +1818,8 @@ getdns_context_set_suffix(getdns_context *context, getdns_list *value)
getdns_return_t r; getdns_return_t r;
size_t i; size_t i;
gldns_buffer gbuf; gldns_buffer gbuf;
uint8_t buf_spc[1024], *suffix = NULL; uint8_t buf_spc[1024], *suffixes = NULL;
size_t suffix_len = 0; size_t suffixes_len = 0;
uint8_t dname[256]; uint8_t dname[256];
size_t dname_len; size_t dname_len;
char name_spc[1025], *name; char name_spc[1025], *name;
@ -1829,11 +1829,11 @@ getdns_context_set_suffix(getdns_context *context, getdns_list *value)
return GETDNS_RETURN_INVALID_PARAMETER; return GETDNS_RETURN_INVALID_PARAMETER;
if (value == NULL) { if (value == NULL) {
if (context->suffix && context->suffix != no_suffixes) if (context->suffixes && context->suffixes != no_suffixes)
GETDNS_FREE(context->mf, context->suffix); GETDNS_FREE(context->mf, context->suffixes);
context->suffix = no_suffixes; context->suffixes = no_suffixes;
context->suffix_len = sizeof(no_suffixes); context->suffixes_len = sizeof(no_suffixes);
return GETDNS_RETURN_GOOD; return GETDNS_RETURN_GOOD;
} }
gldns_buffer_init_frm_data(&gbuf, buf_spc, sizeof(buf_spc)); gldns_buffer_init_frm_data(&gbuf, buf_spc, sizeof(buf_spc));
@ -1872,28 +1872,28 @@ getdns_context_set_suffix(getdns_context *context, getdns_list *value)
if (gldns_buffer_begin(&gbuf) != buf_spc) if (gldns_buffer_begin(&gbuf) != buf_spc)
break; break;
suffix_len = gldns_buffer_position(&gbuf); suffixes_len = gldns_buffer_position(&gbuf);
if (!(suffix = GETDNS_XMALLOC( if (!(suffixes = GETDNS_XMALLOC(
context->mf, uint8_t, suffix_len))) { context->mf, uint8_t, suffixes_len))) {
r = GETDNS_RETURN_MEMORY_ERROR; r = GETDNS_RETURN_MEMORY_ERROR;
break; break;
} }
if (suffix_len <= gldns_buffer_limit(&gbuf)) { if (suffixes_len <= gldns_buffer_limit(&gbuf)) {
(void) memcpy (suffix, buf_spc, suffix_len); (void) memcpy (suffixes, buf_spc, suffixes_len);
break; break;
} }
gldns_buffer_init_frm_data(&gbuf, suffix, suffix_len); gldns_buffer_init_frm_data(&gbuf, suffixes, suffixes_len);
} }
if (r) { if (r) {
if (gldns_buffer_begin(&gbuf) != buf_spc) if (gldns_buffer_begin(&gbuf) != buf_spc)
GETDNS_FREE(context->mf, suffix); GETDNS_FREE(context->mf, suffixes);
return r; return r;
} }
if (context->suffix && context->suffix != no_suffixes) if (context->suffixes && context->suffixes != no_suffixes)
GETDNS_FREE(context->mf, context->suffix); GETDNS_FREE(context->mf, context->suffixes);
context->suffix = suffix; context->suffixes = suffixes;
context->suffix_len = suffix_len; context->suffixes_len = suffixes_len;
dispatch_updated(context, GETDNS_CONTEXT_CODE_SUFFIX); dispatch_updated(context, GETDNS_CONTEXT_CODE_SUFFIX);
return GETDNS_RETURN_GOOD; return GETDNS_RETURN_GOOD;
@ -3259,9 +3259,9 @@ getdns_context_get_suffix(getdns_context *context, getdns_list **value)
if (!(list = getdns_list_create_with_context(context))) if (!(list = getdns_list_create_with_context(context)))
return GETDNS_RETURN_MEMORY_ERROR; return GETDNS_RETURN_MEMORY_ERROR;
assert(context->suffix); assert(context->suffixes);
dname_len = context->suffix[0]; dname_len = context->suffixes[0];
dname = context->suffix + 1; dname = context->suffixes + 1;
while (dname_len && *dname) { while (dname_len && *dname) {
if (! gldns_wire2str_dname_buf( if (! gldns_wire2str_dname_buf(
dname, dname_len, name, sizeof(name))) { dname, dname_len, name, sizeof(name))) {
@ -3269,7 +3269,7 @@ getdns_context_get_suffix(getdns_context *context, getdns_list **value)
break; break;
} }
if ((r = _getdns_list_append_const_bindata( if ((r = _getdns_list_append_const_bindata(
list, strlen(name), name))) list, strlen(name) + 1, name)))
break; break;
dname += dname_len; dname += dname_len;
dname_len = *dname++; dname_len = *dname++;

View File

@ -183,9 +183,9 @@ struct getdns_context {
* length bytes contains the length of the following dname. * length bytes contains the length of the following dname.
* The last dname should be the zero byte. * The last dname should be the zero byte.
*/ */
uint8_t *suffix; uint8_t *suffixes;
/* Length of all suffixes in the suffix buffer */ /* Length of all suffixes in the suffix buffer */
size_t suffix_len; size_t suffixes_len;
uint8_t *trust_anchors; uint8_t *trust_anchors;
size_t trust_anchors_len; size_t trust_anchors_len;
getdns_upstreams *upstreams; getdns_upstreams *upstreams;