name.c revision 5855fd79e375c74fc9df57ce0b4c4ef1b9fcdc3e
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC")
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * Copyright (C) 1998-2003 Internet Software Consortium.
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * Permission to use, copy, modify, and/or distribute this software for any
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * purpose with or without fee is hereby granted, provided that the above
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * copyright notice and this permission notice appear in all copies.
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1767006bb066ef500b90b432fba79d63d0d09b36Bryan Cantrill * PERFORMANCE OF THIS SOFTWARE.
#include <config.h>
#include <ctype.h>
#include <stdlib.h>
ft_init = 0,
} ft_state;
fw_start = 0,
} fw_state;
static unsigned char maptolower[] = {
#define CONVERTTOASCII(c)
#define CONVERTFROMASCII(c)
var = default;
var = default; \
static unsigned char root_offsets[] = { 0 };
static unsigned char wild_offsets[] = { 0 };
#ifdef ISC_PLATFORM_USETHREADS
static int thread_key_initialized = 0;
return (ISC_FALSE);
return (ISC_FALSE);
offset = 0;
nlabels = 0;
return (ISC_FALSE);
return (ISC_FALSE);
nlabels++;
return (ISC_FALSE);
if (count == 0)
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
n = *ndata++;
return (ISC_FALSE);
return (ISC_FALSE);
n = *ndata++;
if (first || n == 0) {
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_TRUE);
n = *ndata++;
if (first || n == 0) {
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
unsigned char *ndata;
return (ISC_TRUE);
return (ISC_FALSE);
unsigned char *ndata;
unsigned int count;
unsigned int label;
return (ISC_TRUE);
label++;
return (ISC_FALSE);
unsigned int length;
if (case_sensitive) {
while (length > 0) {
length--;
while (length > 0) {
c = maptolower[*s];
length--;
unsigned char *offsets;
*orderp = 0;
return (dns_namereln_equal);
nlabels = 0;
l = l1;
l = l2;
l1--;
l2--;
if (cdiff < 0)
while (count > 0) {
if (chdiff != 0) {
goto done;
count--;
label1++;
label2++;
if (cdiff != 0) {
goto done;
nlabels++;
if (ldiff < 0)
else if (ldiff > 0)
done:
return (namereln);
int order;
unsigned int nlabels;
return (order);
unsigned int l, count;
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
while (count > 0) {
count--;
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
while (count > 0) {
count--;
int order;
unsigned int nlabels;
return (ISC_TRUE);
return (ISC_FALSE);
int order;
#if defined(__clang__) && \
return (ISC_TRUE);
return (ISC_FALSE);
unsigned char *offsets;
unsigned int first, unsigned int n,
unsigned char *offsets;
unsigned char *offsets;
unsigned int len;
if (r->length > 0)
char *tdata;
unsigned char *offsets;
offsets[0] = 0;
tused = 0;
nused = 0;
labels = 0;
c = *tdata++;
tlen--;
tused++;
switch (state) {
case ft_init:
if (tlen != 0)
return (DNS_R_EMPTYLABEL);
labels++;
*ndata++ = 0;
nrem--;
nused++;
case ft_start:
ndata++;
nrem--;
nused++;
count = 0;
if (nrem == 0)
return (ISC_R_NOSPACE);
case ft_ordinary:
if (count == 0)
return (DNS_R_EMPTYLABEL);
labels++;
if (tlen == 0) {
labels++;
*ndata++ = 0;
nrem--;
nused++;
return (DNS_R_LABELTOOLONG);
count++;
CONVERTTOASCII(c);
if (downcase)
*ndata++ = c;
nrem--;
nused++;
case ft_initialescape:
return (DNS_R_BADLABELTYPE);
case ft_escape:
return (DNS_R_LABELTOOLONG);
count++;
CONVERTTOASCII(c);
if (downcase)
*ndata++ = c;
nrem--;
nused++;
digits = 0;
value = 0;
case ft_escdecimal:
return (DNS_R_BADESCAPE);
digits++;
return (DNS_R_BADESCAPE);
return (DNS_R_LABELTOOLONG);
count++;
if (downcase)
nrem--;
nused++;
if (!done) {
if (nrem == 0)
return (ISC_R_NOSPACE);
return (ISC_R_UNEXPECTEDEND);
labels++;
return (ISC_R_NOSPACE);
while (n1 > 0) {
while (n2 > 0) {
c = *label++;
if (downcase)
*ndata++ = c;
n2--;
labels++;
if (n1 > 0) {
return (ISC_R_SUCCESS);
#ifdef ISC_PLATFORM_USETHREADS
thread_key_mutex_init(void) {
static isc_result_t
totext_filter_proc_key_init(void) {
return (result);
if (!thread_key_initialized) {
goto unlock;
if (!thread_key_initialized &&
free_specific) != 0) {
return (result);
if (omit_final_dot)
unsigned char *ndata;
char *tdata;
unsigned int labels;
#ifdef ISC_PLATFORM_USETHREADS
#ifdef ISC_PLATFORM_USETHREADS
return (result);
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
nlen = 0;
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
nlen = 0;
labels--;
nlen--;
if (count == 0) {
while (count > 0) {
c = *ndata;
goto no_escape;
return (ISC_R_NOSPACE);
CONVERTFROMASCII(c);
*tdata++ = c;
ndata++;
nlen--;
if (trem == 0)
return (ISC_R_NOSPACE);
CONVERTFROMASCII(c);
*tdata++ = c;
ndata++;
trem--;
nlen--;
return (ISC_R_NOSPACE);
ndata++;
nlen--;
count--;
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
return (ISC_R_NOSPACE);
trem++;
#ifdef ISC_PLATFORM_USETHREADS
return (ISC_R_SUCCESS);
unsigned char *ndata;
char *tdata;
unsigned int labels;
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
nlen = 0;
labels--;
nlen--;
if (count == 0)
while (count > 0) {
c = *ndata;
if (trem == 0)
return (ISC_R_NOSPACE);
CONVERTFROMASCII(c);
*tdata++ = c;
ndata++;
trem--;
nlen--;
return (ISC_R_NOSPACE);
ndata++;
nlen--;
count--;
if (trem == 0)
return (ISC_R_NOSPACE);
trem--;
return (ISC_R_NOSPACE);
if (omit_final_dot)
trem++;
return (ISC_R_SUCCESS);
return (ISC_R_NOSPACE);
labels--;
nlen--;
while (count > 0) {
nlen--;
count--;
return (ISC_R_SUCCESS);
unsigned char *ndata;
offset = 0;
nlabels = 0;
offset++;
if (count == 0) {
if (absolute)
unsigned char *offsets;
new_current = 0;
labels = 0;
nused = 0;
cused = 0;
c = *cdata++;
current++;
if (!seen_pointer)
cused++;
switch (state) {
case fw_start:
labels++;
goto full;
*ndata++ = c;
return (DNS_R_BADLABELTYPE);
return (DNS_R_DISALLOWED);
return (DNS_R_BADLABELTYPE);
case fw_ordinary:
if (downcase)
c = maptolower[c];
*ndata++ = c;
case fw_newcurrent:
new_current += c;
return (DNS_R_BADPOINTER);
if (!done)
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_SUCCESS);
full:
return (DNS_R_NAMETOOLONG);
return (ISC_R_NOSPACE);
unsigned int methods;
#if defined(__clang__) && \
if (gf) {
return (ISC_R_NOSPACE);
return (ISC_R_NOSPACE);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
if (copy_prefix &&
length = 0;
prefix_length = 0;
labels = 0;
if (copy_prefix) {
if (copy_suffix) {
return (DNS_R_NAMETOOLONG);
return (ISC_R_NOSPACE);
if (copy_suffix) {
if (absolute)
return (ISC_R_SUCCESS);
unsigned int splitlabel;
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
isc_region_t r;
#if defined(__clang__) && \
return (result);
isc_buffer_t b;
isc_region_t r;
isc_buffer_init(&b, t, sizeof(t));
return (result);
isc_buffer_usedregion(&b, &r);
return (ISC_R_SUCCESS);
#ifdef ISC_PLATFORM_USETHREADS
int res;
return (result);
return (ISC_R_SUCCESS);
if (res != 0)
return (result);
return (ISC_R_NOMEMORY);
return (result);
return (ISC_R_SUCCESS);
isc_region_t r;
return (result);
if (p == NULL)
return (ISC_R_NOMEMORY);
*target = p;
return (ISC_R_SUCCESS);
return (result);
return (result);
unsigned char *ndata;
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
dns_name_destroy(void) {
#ifdef ISC_PLATFORM_USETHREADS
== ISC_R_SUCCESS);
if (thread_key_initialized) {
size_t i;
return (ISC_TRUE);
return (ISC_FALSE);