aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-06-06 06:06:02 +0000
committerUlrich Drepper <drepper@redhat.com>2004-06-06 06:06:02 +0000
commit40c38b6c9d4b49d509630dccb55cf529b3da3d89 (patch)
treedc727938810ecd6787700960f57ebd6c090ff42f /nscd/nscd_getgr_r.c
parentDon't expand _itoa inline for libc. (diff)
downloadglibc-40c38b6c9d4b49d509630dccb55cf529b3da3d89.tar.gz
glibc-40c38b6c9d4b49d509630dccb55cf529b3da3d89.tar.bz2
glibc-40c38b6c9d4b49d509630dccb55cf529b3da3d89.zip
Update.
2004-06-05 Ulrich Drepper <drepper@redhat.com> * stdio-common/_itoa.h: Don't expand _itoa inline for libc. * stdio-common/_itoa.c: Add _itoa implementation. * nscd/nscd_gethst_r.c (__nscd_open_socket): Change implementation to also send request. Add parameter to allow this. Change callers. * nscd/nscd_getgr_r.c: Change __nscd_open_socket caller. * nscd/nscd_getpw_r.c: Likewise. * nscd/nscd-client.h: Change __nscd_open_socket prototype.
Diffstat (limited to 'nscd/nscd_getgr_r.c')
-rw-r--r--nscd/nscd_getgr_r.c41
1 files changed, 11 insertions, 30 deletions
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index f6b0b5c3b0..c57c6e7e61 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -28,6 +28,7 @@
#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/un.h>
+#include <not-cancel.h>
#include "nscd-client.h"
#include "nscd_proto.h"
@@ -53,12 +54,12 @@ int
__nscd_getgrgid_r (gid_t gid, struct group *resultbuf, char *buffer,
size_t buflen, struct group **result)
{
- char buf[12];
- size_t n;
+ char buf[3 * sizeof (gid_t)];
+ buf[sizeof (buf) - 1] = '\0';
+ char *cp = _itoa_word (gid, buf + sizeof (buf) - 1, 10, 0);
- n = __snprintf (buf, sizeof (buf), "%d", gid) + 1;
-
- return nscd_getgr_r (buf, n, GETGRBYGID, resultbuf, buffer, buflen, result);
+ return nscd_getgr_r (cp, buf + sizeof (buf) - cp, GETGRBYGID, resultbuf,
+ buffer, buflen, result);
}
@@ -68,13 +69,9 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
struct group *resultbuf, char *buffer, size_t buflen,
struct group **result)
{
- int sock = __nscd_open_socket ();
- request_header req;
gr_response_header gr_resp;
- ssize_t nbytes;
- struct iovec vec[2];
- int retval = -1;
-
+ int sock = __nscd_open_socket (key, keylen, type, &gr_resp,
+ sizeof (gr_resp));
if (sock == -1)
{
__nss_not_use_nscd_group = 1;
@@ -82,26 +79,9 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
}
/* No value found so far. */
+ int retval = -1;
*result = NULL;
- req.version = NSCD_VERSION;
- req.type = type;
- req.key_len = keylen;
-
- vec[0].iov_base = &req;
- vec[0].iov_len = sizeof (request_header);
- vec[1].iov_base = (void *) key;
- vec[1].iov_len = keylen;
-
- nbytes = TEMP_FAILURE_RETRY (__writev (sock, vec, 2));
- if (nbytes != (ssize_t) (sizeof (request_header) + keylen))
- goto out;
-
- nbytes = TEMP_FAILURE_RETRY (__read (sock, &gr_resp,
- sizeof (gr_response_header)));
- if (nbytes != (ssize_t) sizeof (gr_response_header))
- goto out;
-
if (gr_resp.found == -1)
{
/* The daemon does not cache this database. */
@@ -111,6 +91,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
if (gr_resp.found == 1)
{
+ struct iovec vec[2];
uint32_t *len;
char *p = buffer;
size_t total_len;
@@ -196,7 +177,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
}
out:
- __close (sock);
+ close_not_cancel_no_status (sock);
return retval;
}