Module Name: src
Committed By: dsl
Date: Tue Feb 19 23:29:16 UTC 2013
Modified Files:
src/usr.bin/ftp: util.c
Log Message:
When using the response to SYST to decide whether to default to 'binary'
be a lot less specific.
Kyocera printers report "230 Linux" but really don't want text transfers
of pdf files!
To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/usr.bin/ftp/util.c
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.157 src/usr.bin/ftp/util.c:1.158
--- src/usr.bin/ftp/util.c:1.157 Wed Jul 4 06:09:37 2012
+++ src/usr.bin/ftp/util.c Tue Feb 19 23:29:15 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.157 2012/07/04 06:09:37 is Exp $ */
+/* $NetBSD: util.c,v 1.158 2013/02/19 23:29:15 dsl 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.157 2012/07/04 06:09:37 is Exp $");
+__RCSID("$NetBSD: util.c,v 1.158 2013/02/19 23:29:15 dsl Exp $");
#endif /* not lint */
/*
@@ -202,25 +202,20 @@ getremoteinfo(void)
/* determine remote system type */
if (command("SYST") == COMPLETE) {
if (overbose) {
- char *cp, c;
-
- c = 0;
- cp = strchr(reply_string + 4, ' ');
- if (cp == NULL)
- cp = strchr(reply_string + 4, '\r');
- if (cp) {
- if (cp[-1] == '.')
- cp--;
- c = *cp;
- *cp = '\0';
- }
-
- fprintf(ttyout, "Remote system type is %s.\n",
- reply_string + 4);
- if (cp)
- *cp = c;
+ int os_len = strcspn(reply_string + 4, " \r\n\t");
+ if (os_len > 1 && reply_string[4 + os_len - 1] == '.')
+ os_len--;
+ fprintf(ttyout, "Remote system type is %.*s.\n",
+ os_len, reply_string + 4);
}
- if (!strncmp(reply_string, "215 UNIX Type: L8", 17)) {
+ /*
+ * Decide whether we should default to bninary.
+ * Traditionally checked for "215 UNIX Type: L8", but
+ * some printers report "Linux" ! so be more forgiving.
+ * In reality we probably almost never want text any more.
+ */
+ if (!strncasecmp(reply_string + 4, "unix", 4) ||
+ !strncasecmp(reply_string + 4, "linux", 5)) {
if (proxy)
unix_proxy = 1;
else