1 /* Skip over a (potentially compressed) domain name in wire format.
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 <arpa/nameser.h>
20 #include <shlib-compat.h>
22 /* Advances *PTRPTR to skip over the compressed name it points at.
23 Returns 0 on success, -1 (with errno set) on failure. */
25 ___ns_name_skip (const unsigned char **ptrptr
, const unsigned char *eom
)
27 const unsigned char *cp
;
36 /* End of domain name without indirection. */
41 /* Check for indirection. */
42 switch (n
& NS_CMPRSFLGS
)
44 case 0: /* Normal case, n == len. */
49 case NS_CMPRSFLGS
: /* Indirection. */
51 /* No room for second indirection byte. */
55 default: /* Illegal type. */
61 __set_errno (EMSGSIZE
);
64 versioned_symbol (libc
, ___ns_name_skip
, ns_name_skip
, GLIBC_2_34
);
65 versioned_symbol (libc
, ___ns_name_skip
, __ns_name_skip
, GLIBC_PRIVATE
);
66 libc_hidden_ver (___ns_name_skip
, __ns_name_skip
)
68 #if OTHER_SHLIB_COMPAT (libresolv, GLIBC_2_9, GLIBC_2_34)
69 compat_symbol (libresolv
, ___ns_name_skip
, ns_name_skip
, GLIBC_2_9
);