From 42c2a348fe60538f961af84387aa29418150ca1e Mon Sep 17 00:00:00 2001 From: Jason Downs Date: Wed, 7 Aug 1996 03:17:59 +0000 Subject: strcpy -> strncpy, kill off a strdup() clone. --- libexec/ftpd/ftpcmd.y | 18 +++--------------- libexec/ftpd/ftpd.c | 4 ++-- 2 files changed, 5 insertions(+), 17 deletions(-) (limited to 'libexec') 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++) { -- cgit v1.2.3