From 816fc22a4a618bde48f6dd5e32499fa1459279b5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 4 Oct 2009 07:36:58 +0200 Subject: [PATCH] [MINOR] stats: strip CR and LF from the input command line commands sent from certain tools (eg: telnet) will be terminated by CRLF and not only LF. So we must suppress CR too. --- src/dumpstats.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dumpstats.c b/src/dumpstats.c index b34b84997..8b9593306 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -363,13 +363,19 @@ void stats_io_handler(struct stream_interface *si) break; } - /* ensure we have a full line */ - if (trash[reql-1] != '\n') { + /* now it is time to check that we have a full line, + * remove the trailing \n and possibly \r, then cut the + * line. + */ + len = reql - 1; + if (trash[len] != '\n') { s->ana_state = STATS_ST_CLOSE; continue; } - len = reql - 1; + if (len && trash[len-1] == '\r') + len--; + trash[len] = '\0'; si->st0 = 1; // default to prompt