summaryrefslogtreecommitdiffstats
path: root/usr.bin/rpcgen
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2003-04-14 04:51:28 +0000
committerderaadt <deraadt@openbsd.org>2003-04-14 04:51:28 +0000
commit64408149ed46f5bad6c46609d83f9f5628690087 (patch)
tree579f59756bca5d99776dfcb16cbfd9060209887a /usr.bin/rpcgen
parentremove old comment (diff)
downloadwireguard-openbsd-64408149ed46f5bad6c46609d83f9f5628690087.tar.xz
wireguard-openbsd-64408149ed46f5bad6c46609d83f9f5628690087.zip
strlcpy, pretty easy
Diffstat (limited to 'usr.bin/rpcgen')
-rw-r--r--usr.bin/rpcgen/rpc_main.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index 4b86a36078c..eb3c5543631 100644
--- a/usr.bin/rpcgen/rpc_main.c
+++ b/usr.bin/rpcgen/rpc_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_main.c,v 1.15 2002/07/05 05:39:42 deraadt Exp $ */
+/* $OpenBSD: rpc_main.c,v 1.16 2003/04/14 04:51:28 deraadt Exp $ */
/* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -32,7 +32,7 @@
#ifndef lint
static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
-static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.15 2002/07/05 05:39:42 deraadt Exp $";
+static char cvsid[] = "$OpenBSD: rpc_main.c,v 1.16 2003/04/14 04:51:28 deraadt Exp $";
#endif
/*
@@ -224,13 +224,15 @@ extendfile(path, ext)
char *file;
char *res;
char *p;
+ size_t len;
if ((file = strrchr(path, '/')) == NULL)
file = path;
else
file++;
- res = alloc(strlen(file) + strlen(ext) + 1);
+ len = strlen(file) + strlen(ext) + 1;
+ res = alloc(len);
if (res == NULL) {
fprintf(stderr, "could not allocate memory\n");
exit(1);
@@ -238,8 +240,8 @@ extendfile(path, ext)
p = strrchr(file, '.');
if (p == NULL)
p = file + strlen(file);
- (void) strcpy(res, file);
- (void) strcpy(res + (p - file), ext);
+ (void) strlcpy(res, file, len);
+ (void) strlcpy(res, ext, len - (p - file));
return (res);
}