diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-01-12 14:57:15 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-01-12 14:57:15 +0000 |
commit | d1c129764c30a1294a991a1832e80e862ce9a4aa (patch) | |
tree | 6434eed39b2af29acb218862bde251dfe91f851c /nis/nis_subr.c | |
parent | f40372e632b5bef034a9cfc23ba7e6a85680fb79 (diff) | |
download | glibc-d1c129764c30a1294a991a1832e80e862ce9a4aa.tar glibc-d1c129764c30a1294a991a1832e80e862ce9a4aa.tar.gz glibc-d1c129764c30a1294a991a1832e80e862ce9a4aa.tar.bz2 glibc-d1c129764c30a1294a991a1832e80e862ce9a4aa.zip |
* nis/nis_subr.c (nis_getnames): Add trailing dot to NIS_PATH
components which lack them.
* nis/nis_subr.c (nis_getnames): Make sure that we always return
at least one entry consisting of the parameter concatenated with
the domain.
Diffstat (limited to 'nis/nis_subr.c')
-rw-r--r-- | nis/nis_subr.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/nis/nis_subr.c b/nis/nis_subr.c index 40c9270501..c68189e541 100644 --- a/nis/nis_subr.c +++ b/nis/nis_subr.c @@ -251,13 +251,16 @@ nis_getnames (const_nis_name name) { char *p; - tmp = malloc (cplen + name_len + 2); + tmp = malloc (cplen + name_len + 3); if (__builtin_expect (tmp == NULL, 0)) goto free_null; - p = __stpcpy (tmp, name); + p = __mempcpy (tmp, name, name_len); *p++ = '.'; - memcpy (p, cp, cplen + 1); + p = __mempcpy (p, cp, cplen); + if (p[-1] != '.') + *p++ = '.'; + *p = '\0'; } if (pos >= count) @@ -275,6 +278,13 @@ nis_getnames (const_nis_name name) cp = __strtok_r (NULL, ":", &saveptr); } + if (pos == 0 + && __asprintf (&getnames[pos++], "%s%s%s%s", + name, name[name_len - 1] == '.' ? "" : ".", + local_domain, + local_domain[local_domain_len - 1] == '.' ? "" : ".") < 0) + goto free_null; + getnames[pos] = NULL; return getnames; |