]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ptyfwd: use usec_add() 36791/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 Mar 2025 02:30:36 +0000 (11:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 Mar 2025 02:41:25 +0000 (11:41 +0900)
Fixes CID#1548038.

src/shared/ptyfwd.c

index d434f8e850f0b5291dc383e4d143ab919645674a..affa3ba37ca7ced1ee06d698e4ea813af34e58a5 100644 (file)
@@ -222,11 +222,11 @@ static RequestOperation look_for_escape(PTYForward *f, const char *buffer, size_
                 case 0x1D: { /* Check for ^] */
                         usec_t nw = now(CLOCK_MONOTONIC);
 
-                        if (f->escape_counter == 0 || nw > f->escape_timestamp + ESCAPE_USEC) {
+                        if (f->escape_counter == 0 || nw > usec_add(f->escape_timestamp, ESCAPE_USEC)) {
                                 f->escape_timestamp = nw;
                                 f->escape_counter = 1;
                         } else {
-                                (f->escape_counter)++;
+                                f->escape_counter++;
 
                                 if (f->escape_counter >= 3)
                                         return REQUEST_EXIT;
@@ -237,7 +237,7 @@ static RequestOperation look_for_escape(PTYForward *f, const char *buffer, size_
 
                 case 'a'...'z':
                         if (f->escape_counter == 2 &&
-                            now(CLOCK_MONOTONIC) <= f->escape_timestamp + ESCAPE_USEC) {
+                            now(CLOCK_MONOTONIC) <= usec_add(f->escape_timestamp, ESCAPE_USEC)) {
                                 f->escape_timestamp = 0;
                                 f->escape_counter = 0;
                                 return REQUEST_HOTKEY_BASE + *p;