summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-08-07 03:17:59 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-08-07 03:17:59 +0000
commit42c2a348fe60538f961af84387aa29418150ca1e (patch)
tree915daa0065928ca3e295a0a6445df5c7e294310f /libexec
parent2c3ae82e064d595dcfd2dcdb653c6c3ae61ac77b (diff)
strcpy -> strncpy, kill off a strdup() clone.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ftpd/ftpcmd.y18
-rw-r--r--libexec/ftpd/ftpd.c4
2 files changed, 5 insertions, 17 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index 90a0b38c254..e3020975cbc 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -808,7 +808,6 @@ struct tab sitetab[] = {
{ NULL, 0, 0, 0, 0 }
};
-static char *copy __P((char *));
static void help __P((struct tab *, char *));
static struct tab *
lookup __P((struct tab *, char *));
@@ -1031,7 +1030,9 @@ yylex()
*/
if (n > 1 && cbuf[cpos] == '\n') {
cbuf[cpos] = '\0';
- yylval.s = copy(cp);
+ yylval.s = strdup(cp);
+ if (yylval.s == NULL)
+ fatal("Ran out of memory.");
cbuf[cpos] = '\n';
state = ARGS;
return (STRING);
@@ -1151,19 +1152,6 @@ upper(s)
}
}
-static char *
-copy(s)
- char *s;
-{
- char *p;
-
- p = malloc((unsigned) strlen(s) + 1);
- if (p == NULL)
- fatal("Ran out of memory.");
- (void) strcpy(p, s);
- return (p);
-}
-
static void
help(ctab, s)
struct tab *ctab;
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index ea2e74a16ea..2d4bd93f949 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpd.c,v 1.10 1996/08/07 03:04:22 downsj Exp $ */
+/* $OpenBSD: ftpd.c,v 1.11 1996/08/07 03:17:58 downsj Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
@@ -1760,7 +1760,7 @@ gunique(local)
}
if (cp)
*cp = '/';
- (void) strcpy(new, local);
+ (void) strncpy(new, local, sizeof(new));
cp = new + strlen(new);
*cp++ = '.';
for (count = 1; count < 100; count++) {