diff options
Diffstat (limited to 'contrib/bind/lib/irs/lcl_pw.c')
-rw-r--r-- | contrib/bind/lib/irs/lcl_pw.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/contrib/bind/lib/irs/lcl_pw.c b/contrib/bind/lib/irs/lcl_pw.c index 1f3e870..2655677 100644 --- a/contrib/bind/lib/irs/lcl_pw.c +++ b/contrib/bind/lib/irs/lcl_pw.c @@ -32,7 +32,7 @@ */ /* - * Portions Copyright (c) 1996 by Internet Software Consortium. + * Portions Copyright (c) 1996,1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -49,7 +49,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: lcl_pw.c,v 1.16 1998/02/13 01:10:42 halley Exp $"; +static const char rcsid[] = "$Id: lcl_pw.c,v 1.19 1999/01/18 07:46:57 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ /* Extern */ @@ -61,6 +61,10 @@ static int __bind_irs_pw_unneeded; #else #include <sys/param.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <arpa/nameser.h> +#include <resolv.h> #include <db.h> #include <errno.h> @@ -73,6 +77,7 @@ static int __bind_irs_pw_unneeded; #include <utmp.h> #include <unistd.h> +#include <isc/memcluster.h> #include <irs.h> #include "port_after.h" @@ -115,12 +120,12 @@ irs_lcl_pw(struct irs_acc *this) { struct irs_pw *pw; struct pvt *pvt; - if (!(pw = malloc(sizeof *pw))) { + if (!(pw = memget(sizeof *pw))) { errno = ENOMEM; return (NULL); } memset(pw, 0x5e, sizeof *pw); - if (!(pvt = malloc(sizeof *pvt))) { + if (!(pvt = memget(sizeof *pvt))) { free(pw); errno = ENOMEM; return (NULL); @@ -133,6 +138,8 @@ irs_lcl_pw(struct irs_acc *this) { pw->byuid = pw_byuid; pw->rewind = pw_rewind; pw->minimize = pw_minimize; + pw->res_get = NULL; + pw->res_set = NULL; return (pw); } @@ -147,9 +154,9 @@ pw_close(struct irs_pw *this) { pvt->pw_db = NULL; } if (pvt->line) - free(pvt->line); - free(pvt); - free(this); + memput(pvt->line, pvt->max); + memput(pvt, sizeof *pvt); + memput(this, sizeof *this); } static struct passwd * @@ -262,9 +269,20 @@ hashpw(struct irs_pw *this, DBT *key) { if ((pvt->pw_db->get)(pvt->pw_db, key, &data, 0)) return (0); p = (char *)data.data; - if (data.size > pvt->max && - (pvt->line = realloc(pvt->line, pvt->max += 1024)) == NULL) - return (0); + if (data.size > pvt->max) { + size_t newlen = pvt->max + 1024; + char *p = memget(newlen); + if (p == NULL) { + return (0); + } + if (pvt->line != NULL) { + memcpy(p, pvt->line, pvt->max); + memput(pvt->line, pvt->max); + } + pvt->max = newlen; + pvt->line = p; + } + /* THIS CODE MUST MATCH THAT IN pwd_mkdb. */ t = pvt->line; l = pvt->line + pvt->max; |