From 06cb545ae6875210fd15444f8f9c6967aaec6952 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Fri, 21 Oct 2022 12:04:41 -0700
Subject: [PATCH] Fix lost 'unexpected characters' received in ANSI get cursor
 position response

Unexpected characters received (maybe typed by the user) were supposed to
be stuffed in the keyboard input buffer using ungetstr(), but the input string
was cleared rather than NUL-terminated before logging the expected character
and calling ungetstr(), so nothing (a blank string) was logged and nothing was
stuffed in the keyboard input-buffer in this case. Just an off-by-one bug.

This should fix issue #304. Thanks to Keyop and Nelgin for their persistence
in reporting and testing (in #synchronet at irc.synchro.net).
---
 src/sbbs3/ansiterm.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sbbs3/ansiterm.cpp b/src/sbbs3/ansiterm.cpp
index e6231ed9f8..4e00ad223d 100644
--- a/src/sbbs3/ansiterm.cpp
+++ b/src/sbbs3/ansiterm.cpp
@@ -250,7 +250,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
             else if(ch=='R' && rsp)
             	break;
 			else {
-				str[rsp] = 0;
+				str[rsp + 1] = 0;
 #ifdef _DEBUG
 				char dbg[128];
 				c_escape_str(str, dbg, sizeof(dbg), /* Ctrl-only? */true);
-- 
GitLab