gh-120378: Fix crash caused by integer overflow in curses (#124555)

This is actually an upstream problem in curses, and has been reported
to them already:
https://lists.gnu.org/archive/html/bug-ncurses/2024-09/msg00101.html

This is a nice workaround in the meantime to prevent the segfault.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
Peter Bierma 2024-10-02 10:31:23 -04:00 committed by GitHub
parent 7bd9dbf8e1
commit c2ba931318
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 105 additions and 27 deletions

View file

@ -1081,6 +1081,14 @@ class TestCurses(unittest.TestCase):
self.assertEqual(curses.LINES, lines)
self.assertEqual(curses.COLS, cols)
with self.assertRaises(OverflowError):
curses.resize_term(35000, 1)
with self.assertRaises(OverflowError):
curses.resize_term(1, 35000)
# GH-120378: Overflow failure in resize_term() causes refresh to fail
tmp = curses.initscr()
tmp.erase()
@requires_curses_func('resizeterm')
def test_resizeterm(self):
curses.update_lines_cols()
@ -1095,6 +1103,14 @@ class TestCurses(unittest.TestCase):
self.assertEqual(curses.LINES, lines)
self.assertEqual(curses.COLS, cols)
with self.assertRaises(OverflowError):
curses.resizeterm(35000, 1)
with self.assertRaises(OverflowError):
curses.resizeterm(1, 35000)
# GH-120378: Overflow failure in resizeterm() causes refresh to fail
tmp = curses.initscr()
tmp.erase()
def test_ungetch(self):
curses.ungetch(b'A')
self.assertEqual(self.stdscr.getkey(), 'A')