NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/58862: Backgammon causes a segfault with a terminal narrower than 72 columns.



>Number:         58862
>Category:       bin
>Synopsis:       Backgammon causes a segfault with a terminal narrower than 72 columns.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 29 21:30:00 +0000 2024
>Originator:     Aran Clauson
>Release:        10.99.10
>Organization:
None
>Environment:
NetBSD owl 10.99.10 NetBSD 10.99.10 (OWL) #0: Mon Jun 17 17:52:11 PDT 2024  root@owl:/root/obj/sys/arch/amd64/compile/OWL amd64
>Description:
Backgammon segfaults with a narrow terminal.  With a narrow terminal, less than 72 columns, the game will default to a scrolling interface.  However, the detection of narrow terminals is inconsistently communicated to the clear function in common_source/fancy.c.  This causes the clear function to mistakenly assume that linect is initialize.  
>How-To-Repeat:
Narrower the terminal to less than 72 columns, launch backgammon, type n for the rules, no for instructions, and w or r for your piece color.
>Fix:
Index: fancy.c
===================================================================
RCS file: /cvsroot/src/games/backgammon/common_source/fancy.c,v
retrieving revision 1.19
diff -u -r1.19 fancy.c
--- fancy.c     22 Aug 2024 20:46:40 -0000      1.19
+++ fancy.c     29 Nov 2024 21:29:18 -0000
@@ -748,8 +748,10 @@
                lUP = (int)strlen(UP);
        if (ND)
                lND = (int)strlen(ND);
-       if (LI < 24 || CO < 72 || !(CL && UP && ND))
+       if (LI < 24 || CO < 72 || !(CL && UP && ND)) {
+               CL = NULL;
                return (0);
+       }
        linect = (int *) calloc(LI + 1, sizeof(int));
        if (linect == NULL) {
                write(2, "\r\nOut of memory!\r\n", 18);



Home | Main Index | Thread Index | Old Index