Module Name: src
Committed By: lukem
Date: Sat Jun 5 13:59:39 UTC 2010
Modified Files:
src/usr.bin/ftp: util.c version.h
Log Message:
In ftpvis(), prevent incomplete escape sequences at end of dst,
and ensure NUL-termination of dst. Also tweak for readibility.
Fix from Uwe Stuehler and Stefan Sperling, via Marc Balmer.
To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/usr.bin/ftp/util.c
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/ftp/version.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/ftp/util.c
diff -u src/usr.bin/ftp/util.c:1.154 src/usr.bin/ftp/util.c:1.155
--- src/usr.bin/ftp/util.c:1.154 Fri Mar 5 07:41:10 2010
+++ src/usr.bin/ftp/util.c Sat Jun 5 13:59:39 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.154 2010/03/05 07:41:10 lukem Exp $ */
+/* $NetBSD: util.c,v 1.155 2010/06/05 13:59:39 lukem Exp $ */
/*-
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: util.c,v 1.154 2010/03/05 07:41:10 lukem Exp $");
+__RCSID("$NetBSD: util.c,v 1.155 2010/06/05 13:59:39 lukem Exp $");
#endif /* not lint */
/*
@@ -1098,9 +1098,8 @@
{
size_t di, si;
- for (di = si = 0;
- src[si] != '\0' && di < dstlen && si < srclen;
- di++, si++) {
+ di = si = 0;
+ while (src[si] != '\0' && di < dstlen && si < srclen) {
switch (src[si]) {
case '\\':
case ' ':
@@ -1108,12 +1107,18 @@
case '\r':
case '\n':
case '"':
- dst[di++] = '\\';
- if (di >= dstlen)
+ /*
+ * Need room for two characters and NUL, avoiding
+ * incomplete escape sequences at end of dst.
+ */
+ if (di >= dstlen - 3)
break;
+ dst[di++] = '\\';
/* FALLTHROUGH */
default:
- dst[di] = src[si];
+ dst[di] = src[si++];
+ if (di < dstlen)
+ di++;
}
}
dst[di] = '\0';
Index: src/usr.bin/ftp/version.h
diff -u src/usr.bin/ftp/version.h:1.81 src/usr.bin/ftp/version.h:1.82
--- src/usr.bin/ftp/version.h:1.81 Fri Mar 5 07:45:40 2010
+++ src/usr.bin/ftp/version.h Sat Jun 5 13:59:39 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.81 2010/03/05 07:45:40 lukem Exp $ */
+/* $NetBSD: version.h,v 1.82 2010/06/05 13:59:39 lukem Exp $ */
/*-
* Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
@@ -34,5 +34,5 @@
#endif
#ifndef FTP_VERSION
-#define FTP_VERSION "20100305"
+#define FTP_VERSION "20100605"
#endif