[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1_100-5-g1d9
From: |
Mats Erik Andersson |
Subject: |
[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1_100-5-g1d9298c |
Date: |
Fri, 04 Oct 2013 21:42:58 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".
The branch, master has been updated
via 1d9298cfaf6dcc690ade8cbfa1a81bedd03197a4 (commit)
from 88488ebc5adbce76551d85945c3033553db666c7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=1d9298cfaf6dcc690ade8cbfa1a81bedd03197a4
commit 1d9298cfaf6dcc690ade8cbfa1a81bedd03197a4
Author: Mats Erik Andersson <address@hidden>
Date: Wed Oct 2 14:26:14 2013 +0200
ftpd: Capture syntax errors.
Scanner and parser were not sufficiently tuned
to each other, and could produce inconclusive
error messages and even duplicate messages from
a single error.
diff --git a/ChangeLog b/ChangeLog
index 0d1aa41..bf3c796 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2013-10-02 Mats Erik Andersson <address@hidden>
+
+ ftpd: Capture syntax errors.
+ Scanner and parser are insufficiently trimmed to
+ each other, producing duplicate and inconclusive
+ diagnostic messages.
+
+ * ftpd/ftpcmd.y (yylex) <STR1 || ZSTR1 || dostr1>:
+ Remove a break at the end, continue into ZSTR2.
+ This allows detection of syntax errors. A test
+ case is `quote site chmod 0750' by a client.
+ (yylex): Call yyerror() only if `yynerrs' is zero.
+ Otherwise both scanner and parser would send error
+ messages to the client. Specify an explicit message
+ in this call to yyerror().
+ (yyerror): Use parameter `s' in reply message, but
+ keep a default message in case `s' is empty. This
+ passes on any diagnostic message from the parser.
+
2013-09-26 Mats Erik Andersson <address@hidden>
ftpd: Implement FEAT and OPTS.
diff --git a/ftpd/ftpcmd.y b/ftpd/ftpcmd.y
index b2f4081..9dcd06c 100644
--- a/ftpd/ftpcmd.y
+++ b/ftpd/ftpcmd.y
@@ -1300,10 +1300,10 @@ check_login
#define CMD 0 /* beginning of command */
#define ARGS 1 /* expect miscellaneous arguments */
#define STR1 2 /* expect SP followed by STRING */
-#define STR2 3 /* expect STRING */
+#define STR2 3 /* expect STRING (must be STR2 + 1)*/
#define OSTR 4 /* optional SP then STRING */
#define ZSTR1 5 /* SP then optional STRING */
-#define ZSTR2 6 /* optional STRING after SP */
+#define ZSTR2 6 /* optional STRING after SP (must be ZSTR1 + 1)
*/
#define SITECMD 7 /* SITE command */
#define NSTR 8 /* Number followed by a string */
#define DLIST 9 /* SP and delimited list for EPRT/EPSV */
@@ -1373,7 +1373,7 @@ static struct tab cmdtab[] = {
/* Long addressing in RFC 1639. Obsoleted in RFC 5797. */
{ "LPRT", LPRT, ARGS, 1, "<sp> af,hal,h0..hn,2,p0,p1" },
{ "LPSV", LPSV, ARGS, 1, "(set server in long passive mode)" },
- { NULL, 0, 0, 0, 0 }
+ { NULL, 0, 0, 0, NULL }
};
static struct tab sitetab[] = {
@@ -1381,7 +1381,7 @@ static struct tab sitetab[] = {
{ "HELP", HELP, OSTR, 1, "[ <sp> <string> ]" },
{ "IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]" },
{ "UMASK", UMASK, ARGS, 1, "[ <sp> umask ]" },
- { NULL, 0, 0, 0, 0 }
+ { NULL, 0, 0, 0, NULL }
};
/* Extensions beyond RFC 959 and RFC 2389. Ordered as implemented. */
@@ -1572,7 +1572,7 @@ yylex (void)
yylval.s = (char*) p->name;
return (p->token);
}
- break;
+ break; /* Command not known. */
case SITECMD:
if (cbuf[cpos] == ' ')
@@ -1607,7 +1607,7 @@ yylex (void)
return (p->token);
}
state = CMD;
- break;
+ break; /* Command not known. */
case OSTR:
if (cbuf[cpos] == '\n')
@@ -1629,7 +1629,7 @@ yylex (void)
return (SP);
}
- break;
+ /* Intentional continuation. */
case ZSTR2:
if (cbuf[cpos] == '\n')
@@ -1653,7 +1653,7 @@ yylex (void)
state = ARGS;
return (STRING);
}
- break;
+ break; /* Empty string, missing NL. */
case NSTR:
if (cbuf[cpos] == ' ')
@@ -1727,7 +1727,7 @@ yylex (void)
yylval.i = c;
return (CHAR);
}
- break;
+ break; /* Not reachable. */
case ARGS:
if (isdigit (cbuf[cpos]))
@@ -1803,13 +1803,33 @@ yylex (void)
case 't':
return (T);
}
- break;
+ break; /* No number, not in [\n ,aAbBcCeEfFiIlLnNpPrRsSttT] */
default:
fatal ("Unknown state in scanner.");
}
- yyerror ((char *) 0);
+ /*
+ * Analysis: Cases when this point is reached.
+ *
+ * CMD: command not known
+ * SITECMD: site command not known (state changed to CMD)
+ *
+ * OSTR, STR1, ZSTR1, STR2, ZSTR2, NSTR:
+ * empty string or string without NL
+ *
+ * ARGS: not a number, not a special character
+ */
+
+ /*
+ * Issue a new error message only if the parser has not
+ * yet reported a complaint. Without this precaution
+ * two messages would be directed to the client, thus
+ * upsetting all following exchange.
+ */
+ if (!yynerrs)
+ yyerror ("command not recognized");
+
state = CMD;
longjmp (errcatch, 0);
} /* for (;;) */
@@ -1980,9 +2000,9 @@ yyerror (const char *s)
{
char *cp;
- (void) s;
cp = strchr (cbuf, '\n');
if (cp != NULL)
*cp = '\0';
- reply (500, "'%s': command not understood.", cbuf);
+
+ reply (500, "'%s': %s", cbuf, (s ? s : "command not understood."));
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 19 +++++++++++++++++++
ftpd/ftpcmd.y | 46 +++++++++++++++++++++++++++++++++-------------
2 files changed, 52 insertions(+), 13 deletions(-)
hooks/post-receive
--
GNU Inetutils
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1_100-5-g1d9298c,
Mats Erik Andersson <=