Hi,

In rare occasions, when invalid UTF-8 sequences are present in the
command line buffer, the loop in x_zots() loops indefinitely because we
have "str < xlp" and "x_col == xx_cols", so the condition for the loop
will be true, but the actual code that increments the "str" pointer in
the x_e_putc2 and x_e_putc3 functions is protected by the condition
"x_col < xx_cols" which is false, and so the pointer remains at the
same value indefinitely.

This patch only fixes the infinite loop problem, not the fondamental
problem of invalid UTF-8 sequences handling. This would really be nice
to have something consistent there because the command line prompt
really goes nuts when such sequences are present.

Thank you,
-- 
Ivan "Colona" Delalande
Index: edit.c
===================================================================
RCS file: /cvs/src/bin/mksh/edit.c,v
retrieving revision 1.275
diff -u -r1.275 edit.c
--- edit.c	5 Jan 2014 21:57:48 -0000	1.275
+++ edit.c	5 Jul 2014 19:55:10 -0000
@@ -1628,7 +1628,7 @@
 	int adj = x_adj_done;
 
 	x_lastcp();
-	while (*str && str < xlp && adj == x_adj_done)
+	while (*str && str < xlp && x_col < xx_cols && adj == x_adj_done)
 		x_zotc3(&str);
 }
 

Reply via email to