Fix an infinite loop in fortune(6).
authorfcambus <fcambus@openbsd.org>
Fri, 2 Jun 2017 20:02:39 +0000 (20:02 +0000)
committerfcambus <fcambus@openbsd.org>
Fri, 2 Jun 2017 20:02:39 +0000 (20:02 +0000)
When invoking fortune with the -l option (to get long dictums only),
the program gets stuck in an infinite loop because fortlen() doesn't
return the fortune length correctly.

OK mestre@, tb@, deraadt@, schwarze@

games/fortune/fortune/fortune.c

index 4d9cd42..41b5b17 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: fortune.c,v 1.55 2016/03/07 22:49:45 tb Exp $ */
+/*     $OpenBSD: fortune.c,v 1.56 2017/06/02 20:02:39 fcambus Exp $    */
 /*     $NetBSD: fortune.c,v 1.8 1995/03/23 08:28:40 cgd Exp $  */
 
 /*-
@@ -218,7 +218,7 @@ fortlen(void)
        char    line[BUFSIZ];
 
        if (!(Fortfile->tbl.str_flags & (STR_RANDOM | STR_ORDERED)))
-               nchar = (Seekpts[1] - Seekpts[0] <= SLEN);
+               nchar = Seekpts[1] - Seekpts[0];
        else {
                open_fp(Fortfile);
                (void) fseek(Fortfile->inf, (long)Seekpts[0], SEEK_SET);