#911128 Infinite Loop in Hangman

Package:
bsdgames
Source:
bsdgames
Description:
collection of classic textual unix games
Submitter:
Joshua Shaffer
Date:
2025-06-03 13:47:01 UTC
Severity:
normal
#911128#5
Date:
2018-10-16 04:47:41 UTC
From:
To:
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 ----
+

#911128#10
Date:
2025-06-03 13:39:15 UTC
From:
To:
I can confirm this exists in the latest (unstable) version 2.17-35.
I was not able to find an upstream project [1] to report that problem.
Any suggestions?

[1] -- <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1107238>