summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-01-08 01:55:28 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-01-08 01:55:28 +0000
commit6e19d7fefd59aff47f308f67f12be0fb00726924 (patch)
tree7ff42b6045a0f465eb33f8ee9c94ca06efcfb566
parent7172e7826c4ae3d221022f25f7f1d67b4dd2f6e9 (diff)
Close potential memory leak wrt "fromname"; inspired by similar FreeBSD
changes.
-rw-r--r--libexec/ftpd/ftpcmd.y26
1 files changed, 15 insertions, 11 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index 5284a99ef20..714fb491763 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpcmd.y,v 1.29 2002/01/08 01:52:00 millert Exp $ */
+/* $OpenBSD: ftpcmd.y,v 1.30 2002/01/08 01:55:27 millert Exp $ */
/* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */
/*
@@ -47,7 +47,7 @@
#if 0
static char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94";
#else
-static char rcsid[] = "$OpenBSD: ftpcmd.y,v 1.29 2002/01/08 01:52:00 millert Exp $";
+static char rcsid[] = "$OpenBSD: ftpcmd.y,v 1.30 2002/01/08 01:55:27 millert Exp $";
#endif
#endif /* not lint */
@@ -148,7 +148,10 @@ cmd_list
: /* empty */
| cmd_list cmd
{
- fromname = (char *) 0;
+ if (fromname) {
+ free(fromname);
+ fromname = NULL;
+ }
restart_point = (off_t) 0;
}
| cmd_list rcmd
@@ -647,24 +650,25 @@ cmd
rcmd
: RNFR check_login SP pathname CRLF
{
- char *renamefrom();
-
restart_point = (off_t) 0;
if ($2 && $4) {
+ if (fromname)
+ free(fromname);
fromname = renamefrom($4);
- if (fromname == NULL && $4) {
+ if (fromname == NULL)
free($4);
- }
- } else {
- if ($4)
- free ($4);
+ } else if ($4) {
+ free ($4);
}
}
| REST check_login SP byte_size CRLF
{
if ($2) {
- fromname = NULL;
+ if (fromname) {
+ free(fromname);
+ fromname = NULL;
+ }
restart_point = $4; /* XXX $4 is only "int" */
reply(350, "Restarting at %qd. %s", restart_point,
"Send STORE or RETRIEVE to initiate transfer.");