Source-Changes-HG archive

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

[src/trunk]: src/libexec/ftpd in replydirname(), avoid one-byte overrun.



details:   https://anonhg.NetBSD.org/src/rev/bd446e295123
branches:  trunk
changeset: 500046:bd446e295123
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Dec 04 10:50:39 2000 +0000

description:
in replydirname(), avoid one-byte overrun.
From: Kristian Vlaardingerbroek <kris%obit.nl@localhost> (to bugs@openbsd)

diffstat:

 libexec/ftpd/cmds.c    |  22 ++++++++++++++--------
 libexec/ftpd/version.h |   4 ++--
 2 files changed, 16 insertions(+), 10 deletions(-)

diffs (61 lines):

diff -r beb3b2dbd795 -r bd446e295123 libexec/ftpd/cmds.c
--- a/libexec/ftpd/cmds.c       Mon Dec 04 09:59:48 2000 +0000
+++ b/libexec/ftpd/cmds.c       Mon Dec 04 10:50:39 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.8 2000/11/16 13:15:13 lukem Exp $   */
+/*     $NetBSD: cmds.c,v 1.9 2000/12/04 10:50:39 itojun Exp $  */
 
 /*
  * Copyright (c) 1999-2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cmds.c,v 1.8 2000/11/16 13:15:13 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.9 2000/12/04 10:50:39 itojun Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -787,14 +787,20 @@
 static void
 replydirname(const char *name, const char *message)
 {
+       char *p, *ep;
        char npath[MAXPATHLEN];
-       int i;
 
-       for (i = 0; *name != '\0' && i < sizeof(npath) - 1; i++, name++) {
-               npath[i] = *name;
-               if (*name == '"')
-                       npath[++i] = '"';
+       p = npath;
+       ep = &npath[sizeof(npath) - 1];
+       while (*name) {
+               if (*name == '"' && ep - p >= 2) {
+                       *p++ = *name++;
+                       *p++ = '"';
+               } else if (ep - p >= 1)
+                       *p++ = *name++;
+               else
+                       break;
        }
-       npath[i] = '\0';
+       *p = '\0';
        reply(257, "\"%s\" %s", npath, message);
 }
diff -r beb3b2dbd795 -r bd446e295123 libexec/ftpd/version.h
--- a/libexec/ftpd/version.h    Mon Dec 04 09:59:48 2000 +0000
+++ b/libexec/ftpd/version.h    Mon Dec 04 10:50:39 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.25 2000/11/30 02:59:12 lukem Exp $       */
+/*     $NetBSD: version.h,v 1.26 2000/12/04 10:50:39 itojun Exp $      */
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,5 +36,5 @@
  */
 
 #ifndef FTPD_VERSION
-#define        FTPD_VERSION    "NetBSD-ftpd 20001130"
+#define        FTPD_VERSION    "NetBSD-ftpd 20001204"
 #endif



Home | Main Index | Thread Index | Old Index