diff options
Diffstat (limited to 'lib/nss_wrapper/nss_wrapper.c')
-rw-r--r-- | lib/nss_wrapper/nss_wrapper.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c index e3943ee61b..57003bd612 100644 --- a/lib/nss_wrapper/nss_wrapper.c +++ b/lib/nss_wrapper/nss_wrapper.c @@ -49,6 +49,7 @@ #include <string.h> #include <unistd.h> #include <ctype.h> +#include <limits.h> /* * Defining _POSIX_PTHREAD_SEMANTICS before including pwd.h and grp.h gives us @@ -2351,10 +2352,18 @@ static void nwrap_files_endgrent(struct nwrap_backend *b) static struct hostent *nwrap_files_gethostbyname(const char *name, int af) { struct hostent *he; + char canon_name[HOST_NAME_MAX] = { 0 }; + size_t name_len; int i; nwrap_files_cache_reload(nwrap_he_global.cache); + name_len = strlen(name); + if (name_len < sizeof(canon_name) && name[name_len - 1] == '.') { + strncpy(canon_name, name, name_len - 1); + name = canon_name; + } + for (i = 0; i < nwrap_he_global.num; i++) { int j; |