diff options
Diffstat (limited to 'nis/nss_nis/nis-pwd.c')
-rw-r--r-- | nis/nss_nis/nis-pwd.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c index a996b042c4..7972118c84 100644 --- a/nis/nss_nis/nis-pwd.c +++ b/nis/nss_nis/nis-pwd.c @@ -42,34 +42,21 @@ __libc_lock_define_initialized (static, lock) static bool_t new_start = 1; static char *oldkey; static int oldkeylen; - -struct response_t -{ - struct response_t *next; - size_t size; - char mem[0]; -}; - -typedef struct intern_t -{ - struct response_t *start; - struct response_t *next; - size_t offset; -} intern_t; - static intern_t intern; -static int -saveit (int instatus, char *inkey, int inkeylen, char *inval, - int invallen, char *indata) +int +_nis_saveit (int instatus, char *inkey, int inkeylen, char *inval, + int invallen, char *indata) { + intern_t *intern = (intern_t *) indata; + if (instatus != YP_TRUE) return 1; if (inkey && inkeylen > 0 && inval && invallen > 0) { - struct response_t *bucket = intern.next; + struct response_t *bucket = intern->next; if (__builtin_expect (bucket == NULL, 0)) { @@ -82,10 +69,10 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval, bucket->next = NULL; bucket->size = minsize; - intern.start = intern.next = bucket; - intern.offset = 0; + intern->start = intern->next = bucket; + intern->offset = 0; } - else if (__builtin_expect (invallen + 1 > bucket->size - intern.offset, + else if (__builtin_expect (invallen + 1 > bucket->size - intern->offset, 0)) { /* We need a new (larger) buffer. */ @@ -97,21 +84,21 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval, return 1; /* Mark the old bucket as full. */ - bucket->size = intern.offset; + bucket->size = intern->offset; newp->next = NULL; newp->size = newsize; - bucket = intern.next = bucket->next = newp; - intern.offset = 0; + bucket = intern->next = bucket->next = newp; + intern->offset = 0; } - char *p = mempcpy (&bucket->mem[intern.offset], inval, invallen); + char *p = mempcpy (&bucket->mem[intern->offset], inval, invallen); if (__builtin_expect (p[-1] != '\0', 0)) { *p = '\0'; ++invallen; } - intern.offset += invallen; + intern->offset += invallen; } return 0; @@ -165,8 +152,8 @@ internal_nis_setpwent (void) struct ypall_callback ypcb; - ypcb.foreach = saveit; - ypcb.data = NULL; + ypcb.foreach = _nis_saveit; + ypcb.data = (char *) &intern; enum nss_status status = yperr2nss (yp_all (domain, "passwd.byname", &ypcb)); |