summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2008-06-25 14:51:28 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2008-06-25 14:51:28 +0000
commit3eb98ad5a38d8d95544673bda852f357b1070ff5 (patch)
treea23973fa8f1fb34ddf8e480f9fbc06df0cadda70
parentbd9c7c00ea19428f1c5a104e266f09a3dc31c43c (diff)
Add _PW_BUF_LEN define and use it instead of hard-coding 1024 for
the buffer size. OK deraadt@
-rw-r--r--include/pwd.h3
-rw-r--r--lib/libc/gen/getpwent.c12
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c6
3 files changed, 11 insertions, 10 deletions
diff --git a/include/pwd.h b/include/pwd.h
index 572ee679dab..b24e7f5e7a2 100644
--- a/include/pwd.h
+++ b/include/pwd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwd.h,v 1.19 2008/06/24 14:31:59 deraadt Exp $ */
+/* $OpenBSD: pwd.h,v 1.20 2008/06/25 14:51:27 millert Exp $ */
/* $NetBSD: pwd.h,v 1.9 1996/05/15 21:36:45 jtc Exp $ */
/*-
@@ -65,6 +65,7 @@
#define _PASSWORD_LEN 128 /* max length, not counting NUL */
#define _PW_NAME_LEN 31 /* max length, not counting NUL */
/* Should be MAXLOGNAME - 1 */
+#define _PW_BUF_LEN 1024 /* length of getpw*_r buffer */
#define _PASSWORD_NOUID 0x01 /* flag for no specified uid. */
#define _PASSWORD_NOGID 0x02 /* flag for no specified gid. */
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index 38c0b9425f4..7c5dc89b9d9 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getpwent.c,v 1.35 2008/06/24 14:27:24 deraadt Exp $ */
+/* $OpenBSD: getpwent.c,v 1.36 2008/06/25 14:51:27 millert Exp $ */
/*
* Copyright (c) 2008 Theo de Raadt
* Copyright (c) 1988, 1993
@@ -57,7 +57,7 @@ static DB *_pw_db; /* password database */
/* Following are used only by setpwent(), getpwent(), and endpwent() */
static struct passwd _pw_passwd; /* password structure */
-static char _pw_string[1024]; /* string pointed to by _pw_passwd */
+static char _pw_string[_PW_BUF_LEN]; /* string pointed to by _pw_passwd */
static int _pw_keynum; /* key counter */
static int _pw_stayopen; /* keep fd's open */
static int _pw_flags; /* password flags */
@@ -84,7 +84,7 @@ static char *__ypcurrent;
static int __ypcurrentlen;
static int __yp_pw_flags;
static struct passwd *__ypproto;
-static char __ypline[1024];
+static char __ypline[_PW_BUF_LEN];
static int __getpwent_has_yppw = -1;
static struct _ypexclude *__ypexhead;
@@ -314,7 +314,7 @@ getpwent(void)
static char *name = NULL;
char *map;
#endif
- char bf[1 + sizeof(_pw_keynum)], pwbuf[1024];
+ char bf[1 + sizeof(_pw_keynum)], pwbuf[_PW_BUF_LEN];
struct passwd *pw = NULL;
DBT key;
@@ -440,7 +440,7 @@ again:
key.size = 1 + sizeof(_pw_keynum);
if (__hashpw(&key, pwbuf, sizeof pwbuf, &_pw_passwd, &_pw_flags)) {
#ifdef YP
- static long __yppbuf[1024 / sizeof(long)];
+ static long __yppbuf[_PW_BUF_LEN / sizeof(long)];
const char *user, *host, *dom;
/* if we don't have YP at all, don't bother. */
@@ -582,7 +582,7 @@ __yppwlookup(int lookup, char *name, uid_t uid, struct passwd *pw,
{
char bf[1 + _PW_NAME_LEN], *ypcurrent = NULL, *map;
int yp_pw_flags = 0, ypcurrentlen, r, s = -1, pw_keynum;
- static long yppbuf[1024 / sizeof(long)];
+ static long yppbuf[_PW_BUF_LEN / sizeof(long)];
struct _ypexclude *ypexhead = NULL;
const char *host, *user, *dom;
DBT key;
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index b55eec1d7dd..17493cf48ef 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwd_mkdb.c,v 1.39 2008/03/17 20:30:16 sobrado Exp $ */
+/* $OpenBSD: pwd_mkdb.c,v 1.40 2008/06/25 14:51:27 millert Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -41,7 +41,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "from: @(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94";
#else
-static const char rcsid[] = "$OpenBSD: pwd_mkdb.c,v 1.39 2008/03/17 20:30:16 sobrado Exp $";
+static const char rcsid[] = "$OpenBSD: pwd_mkdb.c,v 1.40 2008/06/25 14:51:27 millert Exp $";
#endif
#endif /* not lint */
@@ -490,7 +490,7 @@ void
db_store(FILE *fp, FILE *oldfp, DB *edp, DB *dp, struct passwd *pw,
int keytype, char *username, uid_t olduid)
{
- char *p, *t, buf[LINE_MAX * 2], tbuf[1024];
+ char *p, *t, buf[LINE_MAX * 2], tbuf[_PW_BUF_LEN];
int flags = 0, dbmode, found = 0;
static int firsttime = 1;
DBT data, key;