diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-07-19 07:55:27 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-07-19 07:56:21 +0200 |
commit | 08d4a98070c4c4f69c6d04f483d105121effba08 (patch) | |
tree | 8385e0e0976dbef1d62a28cb7dca51bbf47e3331 /resolv/ns_samedomain.c | |
parent | 17d0407a5cac70652f3544e59505c1712b36fd1a (diff) | |
download | glibc-08d4a98070c4c4f69c6d04f483d105121effba08.tar.gz glibc-08d4a98070c4c4f69c6d04f483d105121effba08.tar.xz glibc-08d4a98070c4c4f69c6d04f483d105121effba08.zip |
resolv: Move ns_makecanon into its own file, and into libc
But only as an internal symbol, __libc_ns_makecanon. The libresolv ABI is preserved. This is because the function is deprecated, and it does not make sense to add new symbol versions for deprecated functions. Also reformat the implementation to GNU style. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'resolv/ns_samedomain.c')
-rw-r--r-- | resolv/ns_samedomain.c | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/resolv/ns_samedomain.c b/resolv/ns_samedomain.c index 5d1bf39fc7..cfff2516b0 100644 --- a/resolv/ns_samedomain.c +++ b/resolv/ns_samedomain.c @@ -144,40 +144,6 @@ ns_subdomain(const char *a, const char *b) { } /*% - * make a canonical copy of domain name "src" - * - * notes: - * \code - * foo -> foo. - * foo. -> foo. - * foo.. -> foo. - * foo\. -> foo\.. - * foo\\. -> foo\\. - * \endcode - */ - -int -ns_makecanon(const char *src, char *dst, size_t dstsize) { - size_t n = strlen(src); - - if (n + sizeof "." > dstsize) { /*%< Note: sizeof == 2 */ - __set_errno (EMSGSIZE); - return (-1); - } - strcpy(dst, src); - while (n >= 1U && dst[n - 1] == '.') /*%< Ends in "." */ - if (n >= 2U && dst[n - 2] == '\\' && /*%< Ends in "\." */ - (n < 3U || dst[n - 3] != '\\')) /*%< But not "\\." */ - break; - else - dst[--n] = '\0'; - dst[n++] = '.'; - dst[n] = '\0'; - return (0); -} -libresolv_hidden_def (ns_makecanon) - -/*% * determine whether domain name "a" is the same as domain name "b" * * return: @@ -190,8 +156,8 @@ int ns_samename(const char *a, const char *b) { char ta[NS_MAXDNAME], tb[NS_MAXDNAME]; - if (ns_makecanon(a, ta, sizeof ta) < 0 || - ns_makecanon(b, tb, sizeof tb) < 0) + if (__libc_ns_makecanon(a, ta, sizeof ta) < 0 || + __libc_ns_makecanon(b, tb, sizeof tb) < 0) return (-1); if (strcasecmp(ta, tb) == 0) return (1); |