Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ftpd Stop ftpd changing inetd's 'logname'



details:   https://anonhg.NetBSD.org/src/rev/a04870e867b1
branches:  trunk
changeset: 543222:a04870e867b1
user:      dsl <dsl%NetBSD.org@localhost>
date:      Wed Feb 19 18:26:48 2003 +0000

description:
Stop ftpd changing inetd's 'logname'
Stop buffer overrun if {NGROUPS_MAX} is greater than the compile time
NGROUPS_MAX.
(approved by christos)

diffstat:

 libexec/ftpd/ftpd.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (39 lines):

diff -r 3e93b35c6daf -r a04870e867b1 libexec/ftpd/ftpd.c
--- a/libexec/ftpd/ftpd.c       Wed Feb 19 16:53:26 2003 +0000
+++ b/libexec/ftpd/ftpd.c       Wed Feb 19 18:26:48 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftpd.c,v 1.150 2003/01/22 04:46:08 lukem Exp $ */
+/*     $NetBSD: ftpd.c,v 1.151 2003/02/19 18:26:48 dsl Exp $   */
 
 /*
  * Copyright (c) 1997-2001 The NetBSD Foundation, Inc.
@@ -109,7 +109,7 @@
 #if 0
 static char sccsid[] = "@(#)ftpd.c     8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: ftpd.c,v 1.150 2003/01/22 04:46:08 lukem Exp $");
+__RCSID("$NetBSD: ftpd.c,v 1.151 2003/02/19 18:26:48 dsl Exp $");
 #endif
 #endif /* not lint */
 
@@ -1092,7 +1092,11 @@
        }
        (void) initgroups(pw->pw_name, pw->pw_gid);
                        /* cache groups for cmds.c::matchgroup() */
-       gidcount = getgroups(sizeof(gidlist), gidlist);
+       gidcount = getgroups(0, NULL);
+       if (gidlist)
+               free(gidlist);
+       gidlist = malloc(gidcount * sizeof *gidlist);
+       gidcount = getgroups(gidcount, gidlist);
 
        /* open utmp/wtmp before chroot */
        login_utmp(ttyline, pw->pw_name, remotehost);
@@ -1206,6 +1210,7 @@
                }
                break;
        }
+       setsid();
        setlogin(pw->pw_name);
        if (dropprivs ||
            (curclass.type != CLASS_REAL && 



Home | Main Index | Thread Index | Old Index