]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] stats: strip CR and LF from the input command line
authorWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 05:36:58 +0000 (07:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 07:19:42 +0000 (09:19 +0200)
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

index b34b8499784335252203bc3dad6436a8c7c63e9b..8b9593306f826a6a4626fef5c28bbc13f0865bbc 100644 (file)
@@ -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