Bug#911128: Infinite Loop in Hangman

Joshua Shaffer jbs3600 at gmail.com
Tue Oct 16 05:47:41 BST 2018


Package: bsdgames
Version: 2.17-26build1

In the case where the provided dictionary only has a single word, it will
result in an infinite loop, since the second fgets will always return NULL.

Here is a patch for this very severe problem.

*** bsdgames-2.17/hangman/getword.c     2018-10-16 00:38:37.000000000 -0400
--- bsdgames-2.17_mod/hangman/getword.c 2018-10-16 00:33:45.653529037 -0400
*************** getword()
*** 62,63 ****
!               if (fgets(Word, BUFSIZ, inf) == NULL)
!                       continue;
--- 62,67 ----
!               if (fgets(Word, BUFSIZ, inf) == NULL) {
!                       pos = 0;
!                       fseek(inf,pos,SEEK_SET);
!                       if (fgets(Word, BUFSIZ, inf) == NULL)
!                               goto cont;
!               }
*************** cont:
*** 71 ****
--- 76 ----
+

-- 
*^KB* SENT FROM WORDSTAR 4.0
*^KK*


More information about the Pkg-games-devel mailing list