2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (c) 1996,1999 by Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #include <sys/types.h>
20 #include <netinet/in.h>
21 #include <arpa/nameser.h>
30 # define SPRINTF(x) ((size_t)sprintf x)
34 static int labellen(const u_char
*);
39 * Convert a network strings labels into all lowercase.
42 *\li Number of bytes written to buffer, or -1 (with errno set)
45 *\li Enforces label and domain length limits.
49 ns_name_ntol(const u_char
*src
, u_char
*dst
, size_t dstsiz
)
62 __set_errno (EMSGSIZE
);
65 while ((n
= *cp
++) != 0) {
66 if ((n
& NS_CMPRSFLGS
) == NS_CMPRSFLGS
) {
67 /* Some kind of compression pointer. */
68 __set_errno (EMSGSIZE
);
72 if ((l
= labellen(cp
- 1)) < 0) {
73 __set_errno (EMSGSIZE
);
77 __set_errno (EMSGSIZE
);
80 for ((void)NULL
; l
> 0; l
--) {
93 * Reset dnptrs so that there are no active references to pointers at or
97 ns_name_rollback(const u_char
*src
, const u_char
**dnptrs
,
98 const u_char
**lastdnptr
)
100 while (dnptrs
< lastdnptr
&& *dnptrs
!= NULL
) {
101 if (*dnptrs
>= src
) {
111 /* Return the length of the encoded label starting at LP, or -1 for
112 compression references and extended label types. */
114 labellen (const unsigned char *lp
)