diff options
Diffstat (limited to 'nis/nis_subr.c')
-rw-r--r-- | nis/nis_subr.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/nis/nis_subr.c b/nis/nis_subr.c index 479e11d..780c27f 100644 --- a/nis/nis_subr.c +++ b/nis/nis_subr.c @@ -46,8 +46,16 @@ nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen) return NULL; } - if (i > 1) - strncpy (buffer, name, i - 1); + if (i > 0) + { + if ((size_t)i >= buflen) + { + errno = ERANGE; + return NULL; + } + strncpy (buffer, name, i); + buffer[i] = 0; + } return buffer; } @@ -89,38 +97,6 @@ nis_name_of_r (const_nis_name name, char *buffer, size_t buflen) return buffer; } -nis_name -nis_domain_of (const_nis_name name) -{ - static char result[NIS_MAXNAMELEN + 1]; - - return nis_domain_of_r (name, result, NIS_MAXNAMELEN); -} - -nis_name -nis_domain_of_r (const_nis_name name, char *buffer, size_t buflen) -{ - char *cptr; - size_t cptr_len; - - cptr = strchr (name, '.'); /* XXX What happens if the NIS name - does not contain a `.'? */ - ++cptr; - cptr_len = strlen (cptr); - - if (cptr_len == 0) - strcpy (buffer, "."); - else if (cptr_len >= buflen) - { - errno = ERANGE; - return NULL; - } - else - memcpy (buffer, cptr, cptr_len + 1); - - return buffer; -} - static int count_dots (const_nis_name str) { |