1 /* Add missing "." to domain names.
2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (c) 1995,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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
10 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
11 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
12 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
15 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
19 #include <arpa/nameser.h>
23 /* Make a canonical copy of domain name SRC in DST. Behavior:
30 __libc_ns_makecanon (const char *src
, char *dst
, size_t dstsize
)
32 size_t n
= strlen (src
);
34 if (n
+ sizeof "." > dstsize
) /* sizeof == 2. */
36 __set_errno (EMSGSIZE
);
40 while (n
>= 1U && dst
[n
- 1] == '.') /* Ends in ".". */
41 if (n
>= 2U && dst
[n
- 2] == '\\' && /* Ends in "\.". */
42 (n
< 3U || dst
[n
- 3] != '\\')) /* But not "\\.". */
50 libc_hidden_def (__libc_ns_makecanon
)