diff options
Diffstat (limited to 'hesiod/nss_hesiod/hesiod-grp.c')
-rw-r--r-- | hesiod/nss_hesiod/hesiod-grp.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c index 7b0832dbe3..e08b9dca8c 100644 --- a/hesiod/nss_hesiod/hesiod-grp.c +++ b/hesiod/nss_hesiod/hesiod-grp.c @@ -81,13 +81,14 @@ _nss_hesiod_endgrent (void) static enum nss_status lookup (const char *name, const char *type, struct group *grp, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { enum nss_status status; struct parser_data *data = (void *) buffer; size_t linebuflen; char **list; int parse_res; + size_t len; status = internal_setgrent (); if (status != NSS_STATUS_SUCCESS) @@ -98,17 +99,18 @@ lookup (const char *name, const char *type, struct group *grp, return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL; linebuflen = buffer + buflen - data->linebuffer; - if (linebuflen < strlen (*list) + 1) + len = strlen (*list) + 1; + if (linebuflen < len) { hesiod_free_list (context, list); - __set_errno (ERANGE); + *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } - strcpy (buffer, *list); + memcpy (data->linebuffer, *list, len); hesiod_free_list (context, list); - parse_res = _nss_files_parse_grent (buffer, grp, data, buflen); + parse_res = _nss_files_parse_grent (buffer, grp, data, buflen, errnop); if (parse_res < 1) return parse_res == -1 ? NSS_STATUS_TRYAGAIN : NSS_STATUS_NOTFOUND; @@ -117,13 +119,13 @@ lookup (const char *name, const char *type, struct group *grp, enum nss_status _nss_hesiod_getgrnam_r (const char *name, struct group *grp, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { enum nss_status status; __libc_lock_lock (lock); - status = lookup (name, "group", grp, buffer, buflen); + status = lookup (name, "group", grp, buffer, buflen, errnop); __libc_lock_unlock (lock); @@ -132,7 +134,7 @@ _nss_hesiod_getgrnam_r (const char *name, struct group *grp, enum nss_status _nss_hesiod_getgrgid_r (gid_t gid, struct group *grp, - char *buffer, size_t buflen) + char *buffer, size_t buflen, int *errnop) { enum nss_status status = NSS_STATUS_UNAVAIL; char gidstr[21]; /* We will probably never have a gid_t with more @@ -142,7 +144,7 @@ _nss_hesiod_getgrgid_r (gid_t gid, struct group *grp, __libc_lock_lock (lock); - status = lookup (gidstr, "gid", grp, buffer, buflen); + status = lookup (gidstr, "gid", grp, buffer, buflen, errnop); __libc_lock_unlock (lock); |