summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-09-23 06:43:55 +0000
committerderaadt <deraadt@openbsd.org>1996-09-23 06:43:55 +0000
commit2dc7d58f973af19c6c2339f65f233f908473ea4a (patch)
tree1d206f1f24676ecdcabb2197cc4b6d6e8e576596
parentpw_abort() after yp change, does unlock (diff)
downloadwireguard-openbsd-2dc7d58f973af19c6c2339f65f233f908473ea4a.tar.xz
wireguard-openbsd-2dc7d58f973af19c6c2339f65f233f908473ea4a.zip
avoid oflows
-rw-r--r--usr.sbin/rpc.pcnfsd/pcnfsd_v2.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c b/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c
index da9bab8b23b..96889a2b01d 100644
--- a/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c
+++ b/usr.sbin/rpc.pcnfsd/pcnfsd_v2.c
@@ -112,7 +112,7 @@ char pw[64];
int c1, c2;
struct passwd *p;
static u_int extra_gids[EXTRAGIDLEN];
-static char home[256];
+static char home[MAXPATHLEN];
#ifdef USE_YP
char *yphome;
char *cp;
@@ -144,7 +144,8 @@ char *cp;
#ifdef USE_YP
yphome = find_entry(uname, "auto.home");
if(yphome) {
- strcpy(home, yphome);
+ strncpy(home, yphome, sizeof home-1);
+ home[sizeof home-1] = '\0';
free(yphome);
cp = strchr(home, ':');
cp++;
@@ -179,7 +180,8 @@ char *cp;
#ifdef USE_YP
yphome = find_entry(uname, "auto.home");
if(yphome) {
- strcpy(home, yphome);
+ strncpy(home, yphome, sizeof home-1);
+ home[sizeof home-1] = '\0';
free(yphome);
cp = strchr(home, ':');
cp++;
@@ -356,7 +358,8 @@ static char *
my_strdup(s)
char *s;
{
-char *r;
+ char *r;
+
r = (char *)grab(strlen(s)+1);
strcpy(r, s);
return(r);