boggle(6) can only handle board specifications that consist of lower
case letters. Also, it will only handle one boardspec per invocation
and ignore the rest. However, currently boggle(6) only checks whether
the first letter of the first boardspec is lower case and whether the
length is correct. Invalid specs, such as 'boggle nolezeebNqieegei' or
'boggle n123412341234123' will lead to a segfault or a bus error.
Index: bog.c
===================================================================
RCS file: /var/cvs/src/games/boggle/boggle/bog.c,v
retrieving revision 1.32
diff -u -p -r1.32 bog.c
--- bog.c 12 Sep 2016 14:38:58 -0000 1.32
+++ bog.c 12 Sep 2016 18:56:36 -0000
@@ -142,18 +142,17 @@ main(int argc, char *argv[])
argv += 1;
}
- if (argc > 0) {
- if (islower((unsigned char)argv[0][0])) {
- if (strlen(argv[0]) != ncubes) {
- usage();
- } else {
- /* This board is assumed to be valid... */
- bspec = argv[0];
- }
- } else {
- usage();
+ if (argc == 1) {
+ if (strlen(argv[0]) != ncubes) {
+ usage();
}
- }
+ for (p = argv[0]; *p != '\0'; p++)
+ if (!islower((unsigned char)*p))
+ errx(1, "only lower case letters are allowed "
+ "in boardspec");
+ bspec = argv[0];
+ } else if (argc != 0)
+ usage();
if (batch && bspec == NULL)
errx(1, "must give both -b and a board setup");