Skip to content

Commit 71a0a55

Browse files
chrisbramattn
andcommitted
patch 9.2.0288: libvterm: signed integer overflow parsing long CSI args
Problem: Accumulating CSI argument digits without an upper bound causes signed integer overflow when the argument exceeds LONG_MAX. Solution: Clamp CSI argument accumulation to CSI_ARG_MISSING to prevent signed integer overflow (Yasuhiro Matsumoto). closes: #19894 Co-authored-by: Yasuhiro Matsumoto <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 863e85e commit 71a0a55

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/libvterm/src/parser.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
232232
if(c >= '0' && c <= '9') {
233233
if(vt->parser.v.csi.args[vt->parser.v.csi.argi] == CSI_ARG_MISSING)
234234
vt->parser.v.csi.args[vt->parser.v.csi.argi] = 0;
235-
vt->parser.v.csi.args[vt->parser.v.csi.argi] *= 10;
236-
vt->parser.v.csi.args[vt->parser.v.csi.argi] += c - '0';
235+
if(vt->parser.v.csi.args[vt->parser.v.csi.argi] < (CSI_ARG_MISSING - 9) / 10) {
236+
vt->parser.v.csi.args[vt->parser.v.csi.argi] *= 10;
237+
vt->parser.v.csi.args[vt->parser.v.csi.argi] += c - '0';
238+
}
237239
break;
238240
}
239241
if(c == ':') {

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
288,
737739
/**/
738740
287,
739741
/**/

0 commit comments

Comments
 (0)