From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id EDF783844011; Wed, 16 Dec 2020 09:39:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDF783844011 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: pty: Check response for CSI6n more strictly. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano via Cygwin-patches X-Git-Refname: refs/heads/master X-Git-Oldrev: 532b91d24e9496c7988b2b1dda7fc0e8b161f782 X-Git-Newrev: da8cebcdedb07ea1029009c19f6c2dc23216e4dd Message-Id: <20201216093920.EDF783844011@sourceware.org> Date: Wed, 16 Dec 2020 09:39:20 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Dec 2020 09:39:21 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=da8cebcdedb07ea1029009c19f6c2dc23216e4dd commit da8cebcdedb07ea1029009c19f6c2dc23216e4dd Author: Takashi Yano via Cygwin-patches Date: Wed Dec 16 18:10:15 2020 +0900 Cygwin: pty: Check response for CSI6n more strictly. - Previous code to read response for CSI6n allows invalid response such as "CSI Pl; Pc H" other than correct response "CSI Pl; Pc R". With this patch, the response is checked more strictly. Diff: --- winsup/cygwin/fhandler_tty.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 5f38ca8d3..77d9d9b47 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -2682,7 +2682,9 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env) len -= n; *p = '\0'; char *p1 = strrchr (buf, '\033'); - if (p1 == NULL || sscanf (p1, "\033[%d;%dR", &y1, &x1) != 2) + char c; + if (p1 == NULL || sscanf (p1, "\033[%d;%d%c", &y1, &x1, &c) != 3 + || c != 'R') continue; wait_cnt = 0; break; @@ -2715,7 +2717,9 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env) len -= n; *p = '\0'; char *p2 = strrchr (buf, '\033'); - if (p2 == NULL || sscanf (p2, "\033[%d;%dR", &y2, &x2) != 2) + char c; + if (p2 == NULL || sscanf (p2, "\033[%d;%d%c", &y2, &x2, &c) != 3 + || c != 'R') continue; break; }