From ccf50c1df9cf1379e337f695672fecf8331f4706 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Tue, 25 Jan 2022 16:55:58 +0000 Subject: [PATCH] locate statistics: non zero exit on corrupt database --- usr.bin/locate/locate/fastfind.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c index 67d22bfca7b..7340ce15667 100644 --- a/usr.bin/locate/locate/fastfind.c +++ b/usr.bin/locate/locate/fastfind.c @@ -48,6 +48,7 @@ statistic (fp, path_fcodes) register u_char *p, *s; register int c; int count; + int error = 0; u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN]; for (c = 0, p = bigram1, s = bigram2; c < NBG; c++) { @@ -69,6 +70,7 @@ statistic (fp, path_fcodes) if (count < 0 || count > MAXPATHLEN) { /* stop on error and display the statstics anyway */ warnx("corrupted database: %s", path_fcodes); + error = 1; break; } @@ -104,6 +106,9 @@ statistic (fp, path_fcodes) (void)printf("Integers: %ld, ", zwerg); (void)printf("8-Bit characters: %ld\n", umlaut); + /* non zero exit on corrupt database */ + if (error) + exit(error); } #endif /* _LOCATE_STATISTIC_ */