[PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.

Hans-Bernhard Bröker HBBroeker@t-online.de
Sat Feb 29 18:10:00 GMT 2020


One more important note: the current implementation has a potential 
buffer overrun issue, because it writes first, and only then checks 
whether that may have overrun the buffer.  And the check itself is off 
by one, too:

>    wpbuf[wpixput++] = x; \
>    if (wpixput > WPBUF_LEN) \
>     wpixput--; \

That's why my latest code snippet does it differently:

 >      if (ixput < WPBUF_LEN)
 >        {
 >          buf[ixput++] = x;
 >        }



More information about the Cygwin-patches mailing list