Skip to content

Commit 196343d

Browse files
fix: add bounds checking for integer overflow in console.cpp
- console.cpp: Add validation for count variable in cursor movement loop Addresses integer overflow vulnerability (CWE-190) Co-Authored-By: Jake Cosme <[email protected]>
1 parent af5d70d commit 196343d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

common/console.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ namespace console {
405405
do {
406406
count = widths.back();
407407
widths.pop_back();
408-
// Move cursor back, print space, and move cursor back again
408+
if (count < 0 || count > 10000) {
409+
count = 0;
410+
}
409411
for (int i = 0; i < count; i++) {
410412
replace_last(' ');
411413
pop_cursor();

0 commit comments

Comments
 (0)