]> git.proxmox.com Git - vncterm.git/blobdiff - vncterm.c
fix bound checking on cursor move
[vncterm.git] / vncterm.c
index be66a3eb92cf42f28dfbf8cc8d9456967cfaa372..70fccef76db8bd1dc2b149d5c48b64a9ac490571 100644 (file)
--- a/vncterm.c
+++ b/vncterm.c
@@ -1354,6 +1354,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
       }
       break;
     } else if (ch == ';') {
+      vt->esc_has_par = 1;
       vt->esc_count++;
       break;
     } else {
@@ -1404,10 +1405,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
       if (vt->esc_buf[0] == 0) {
        vt->esc_buf[0] = 1;
       }
-      vt->cy -= vt->esc_buf[0];
-      if (vt->cy < 0) {
-       vt->cy = 0;
-      }
+      vncterm_gotoxy (vt, vt->cx, vt->cy - vt->esc_buf[0]);
       break;
     case 'B':
     case 'e':
@@ -1415,10 +1413,7 @@ vncterm_putchar (vncTerm *vt, unicode ch)
       if (vt->esc_buf[0] == 0) {
        vt->esc_buf[0] = 1;
       }
-      vt->cy += vt->esc_buf[0];
-      if (vt->cy >= vt->height) {
-       vt->cy = vt->height - 1;
-      }
+      vncterm_gotoxy (vt, vt->cx, vt->cy + vt->esc_buf[0]);
       break;
     case 'C':
     case 'a':
@@ -1426,20 +1421,14 @@ vncterm_putchar (vncTerm *vt, unicode ch)
       if (vt->esc_buf[0] == 0) {
        vt->esc_buf[0] = 1;
       }
-      vt->cx += vt->esc_buf[0];
-      if (vt->cx >= vt->width) {
-       vt->cx = vt->width - 1;
-      }
+      vncterm_gotoxy (vt, vt->cx + vt->esc_buf[0], vt->cy);
       break;
     case 'D':
       /* move cursor left */
       if (vt->esc_buf[0] == 0) {
        vt->esc_buf[0] = 1;
       }
-      vt->cx -= vt->esc_buf[0];
-      if (vt->cx < 0) {
-       vt->cx = 0;
-      }
+      vncterm_gotoxy (vt, vt->cx - vt->esc_buf[0], vt->cy);
       break;
     case 'G':
     case '`':
@@ -1789,7 +1778,11 @@ vncterm_puts (vncTerm *vt, const char *buf, int len)
            vt->utf_char = (vt->utf_char << 6) | (c & 0x3f);
            vt->utf_count--;
            if (vt->utf_count == 0) {
-             tc = vt->utf_char;
+               if (vt->utf_char <= USHRT_MAX) {
+                 tc = vt->utf_char;
+               } else {
+                 tc = 0;
+               }
            } else {
              continue;
            }