From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id AEA63385E01A; Thu, 26 Mar 2020 11:26:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEA63385E01A 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: serial: avoid overrun of vtime X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: e4f9fc92ac613f0ae6cf44de7fdd6229c50168e4 X-Git-Newrev: 72294cd21175c307a6552416b249fc8d66ee0bbc Message-Id: <20200326112631.AEA63385E01A@sourceware.org> Date: Thu, 26 Mar 2020 11:26:31 +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: Thu, 26 Mar 2020 11:26:31 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=72294cd21175c307a6552416b249fc8d66ee0bbc commit 72294cd21175c307a6552416b249fc8d66ee0bbc Author: Corinna Vinschen Date: Sat Mar 21 10:36:11 2020 +0100 Cygwin: serial: avoid overrun of vtime After changing the type of fhandler_serial::vtime_ to cc_t, vtime_ must be stored in 10s of seconds, not in milliseconds. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler_serial.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 72cb1678d..66e80197b 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -903,7 +903,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t) } else { - vtime_ = t->c_cc[VTIME] * 100; + vtime_ = t->c_cc[VTIME]; vmin_ = t->c_cc[VMIN]; } @@ -925,13 +925,13 @@ fhandler_serial::tcsetattr (int action, const struct termios *t) { /* set timeoout constant appropriately and we will only try to read one character in ReadFile() */ - to.ReadTotalTimeoutConstant = vtime_; + to.ReadTotalTimeoutConstant = vtime_ * 100; to.ReadIntervalTimeout = to.ReadTotalTimeoutMultiplier = MAXDWORD; } else if ((vmin_ > 0) && (vtime_ > 0)) { /* time applies to the interval time for this case */ - to.ReadIntervalTimeout = vtime_; + to.ReadIntervalTimeout = vtime_ * 100; } else if ((vmin_ == 0) && (vtime_ == 0)) { @@ -1138,7 +1138,7 @@ fhandler_serial::tcgetattr (struct termios *t) if (!wbinary ()) t->c_oflag |= ONLCR; - t->c_cc[VTIME] = vtime_ / 100; + t->c_cc[VTIME] = vtime_; t->c_cc[VMIN] = vmin_; debug_printf ("vmin_ %u, vtime_ %u", vmin_, vtime_);