From bd952512eac147864ad25e8bcca5c5094b0d958a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 5 Sep 1999 23:34:47 +0000 Subject: Update. 1999-08-31 H.J. Lu * nscd/nscd_getgr_r.c (nscd_getgr_r): Cleanup the buffer count. --- nscd/nscd_getgr_r.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'nscd') diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c index eb71705..aa9c3fd 100644 --- a/nscd/nscd_getgr_r.c +++ b/nscd/nscd_getgr_r.c @@ -147,19 +147,20 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, align the pointer. */ align = ((__alignof__ (char *) - (p - ((char *) 0))) & (__alignof__ (char *) - 1)); - if (buflen < (align + (1 + gr_resp.gr_mem_cnt) * sizeof (char *) - + gr_resp.gr_name_len + gr_resp.gr_passwd_len)) + total_len = align + (1 + gr_resp.gr_mem_cnt) * sizeof (char *) + + gr_resp.gr_name_len + gr_resp.gr_passwd_len; + if (buflen < total_len) { no_room: __set_errno (ERANGE); __close (sock); return ERANGE; } + buflen -= total_len; p += align; resultbuf->gr_mem = (char **) p; p += (1 + gr_resp.gr_mem_cnt) * sizeof (char *); - buflen -= align + (1 + gr_resp.gr_mem_cnt) * sizeof (char *); /* Set pointers for strings. */ resultbuf->gr_name = p; @@ -180,8 +181,6 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, vec[1].iov_len = gr_resp.gr_name_len + gr_resp.gr_passwd_len; total_len += gr_resp.gr_name_len + gr_resp.gr_passwd_len; - buflen -= gr_resp.gr_name_len + gr_resp.gr_passwd_len; - /* Get this data. */ if (__readv (sock, vec, 2) != total_len) { -- cgit v1.1