summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1998-08-19 17:06:37 +0000
committerderaadt <deraadt@openbsd.org>1998-08-19 17:06:37 +0000
commit07f9aae9620523d1e739855dec7632927a8536e1 (patch)
treed3aa420f99755e35621ceb2fab512a850945cf8a
parentuse correct upper bound (diff)
downloadwireguard-openbsd-07f9aae9620523d1e739855dec7632927a8536e1.tar.xz
wireguard-openbsd-07f9aae9620523d1e739855dec7632927a8536e1.zip
buf oflows; reported by felix@schlund.de but fixed by me because he did not send in a patch
-rw-r--r--usr.sbin/rpc.pcnfsd/pcnfsd_cache.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/rpc.pcnfsd/pcnfsd_cache.c b/usr.sbin/rpc.pcnfsd/pcnfsd_cache.c
index 7868f1a4267..12f5b9d4862 100644
--- a/usr.sbin/rpc.pcnfsd/pcnfsd_cache.c
+++ b/usr.sbin/rpc.pcnfsd/pcnfsd_cache.c
@@ -42,7 +42,7 @@ struct cache
{
int cuid;
int cgid;
- char cpw[32];
+ char cpw[_PASSWORD_LEN];
char cuname[10]; /* keep this even for machines
* with alignment problems */
}User_cache[CACHE_SIZE];
@@ -94,8 +94,10 @@ add_cache_entry(p)
User_cache[i] = User_cache[i - 1];
User_cache[0].cuid = p->pw_uid;
User_cache[0].cgid = p->pw_gid;
- (void)strcpy(User_cache[0].cpw, p->pw_passwd);
- (void)strcpy(User_cache[0].cuname, p->pw_name);
+ (void)strncpy(User_cache[0].cpw, p->pw_passwd, sizeof User_cache[0].cpw-1);
+ User_cache[0].cpw[sizeof User_cache[0].cpw-1] = '\0';
+ (void)strncpy(User_cache[0].cuname, p->pw_name, sizeof User_cache[0].cuname-1);
+ User_cache[0].cuname[sizeof User_cache[0].cuname-1] = '\0';
}