summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authornectar <nectar@FreeBSD.org>2003-04-18 22:07:30 +0000
committernectar <nectar@FreeBSD.org>2003-04-18 22:07:30 +0000
commita9bfff60223a8d07b56fdf6f6b4371cb7dc212a5 (patch)
treeee22756bd50bec1aba21ce943652a3e4d4be824c /lib
parent8d0a63adb53549a82cafbe98830f372ae8a79d7a (diff)
downloadFreeBSD-src-a9bfff60223a8d07b56fdf6f6b4371cb7dc212a5.zip
FreeBSD-src-a9bfff60223a8d07b56fdf6f6b4371cb7dc212a5.tar.gz
Follow-up to revision 1.74: Using the result buffer to store our empty
string was an incredibly dumb idea (of course it will be changed by an NSS module on success!). Use a static empty string instead. Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/getpwent.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index f712644..ec8b5bc 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -91,7 +91,7 @@ int __pw_match_entry(const char *, size_t, enum nss_lookup_type,
const char *, uid_t);
int __pw_parse_entry(char *, size_t, struct passwd *, int, int *errnop);
-static int pwd_init(struct passwd *, char *, size_t);
+static void pwd_init(struct passwd *);
union key {
const char *name;
@@ -268,10 +268,9 @@ getpwent_r(struct passwd *pwd, char *buffer, size_t bufsize,
};
int rv, ret_errno;
+ pwd_init(pwd);
+ ret_errno = 0;
*result = NULL;
- ret_errno = pwd_init(pwd, buffer, bufsize);
- if (ret_errno != 0)
- return (ret_errno);
rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwent_r", defaultsrc,
pwd, buffer, bufsize, &ret_errno);
if (rv == NS_SUCCESS)
@@ -298,10 +297,9 @@ getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t bufsize,
};
int rv, ret_errno;
+ pwd_init(pwd);
+ ret_errno = 0;
*result = NULL;
- ret_errno = pwd_init(pwd, buffer, bufsize);
- if (ret_errno != 0)
- return (ret_errno);
rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwnam_r", defaultsrc,
name, pwd, buffer, bufsize, &ret_errno);
if (rv == NS_SUCCESS)
@@ -328,10 +326,9 @@ getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize,
};
int rv, ret_errno;
+ pwd_init(pwd);
+ ret_errno = 0;
*result = NULL;
- ret_errno = pwd_init(pwd, buffer, bufsize);
- if (ret_errno != 0)
- return (ret_errno);
rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwuid_r", defaultsrc,
uid, pwd, buffer, bufsize, &ret_errno);
if (rv == NS_SUCCESS)
@@ -341,23 +338,20 @@ getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize,
}
-static int
-pwd_init(struct passwd *pwd, char *buffer, size_t bufsize)
+static void
+pwd_init(struct passwd *pwd)
{
+ static char nul[] = "";
- if (bufsize < 1)
- return (ERANGE);
- buffer[0] = '\0';
memset(pwd, 0, sizeof(*pwd));
pwd->pw_uid = (uid_t)-1; /* Considered least likely to lead to */
pwd->pw_gid = (gid_t)-1; /* a security issue. */
- pwd->pw_name = buffer;
- pwd->pw_passwd = buffer;
- pwd->pw_class = buffer;
- pwd->pw_gecos = buffer;
- pwd->pw_dir = buffer;
- pwd->pw_shell = buffer;
- return (0);
+ pwd->pw_name = nul;
+ pwd->pw_passwd = nul;
+ pwd->pw_class = nul;
+ pwd->pw_gecos = nul;
+ pwd->pw_dir = nul;
+ pwd->pw_shell = nul;
}
OpenPOWER on IntegriCloud