git: ccf50c1df9cf - main - locate statistics: non zero exit on corrupt database
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Jan 2022 16:57:25 UTC
The branch main has been updated by wosch: URL: https://cgit.FreeBSD.org/src/commit/?id=ccf50c1df9cf1379e337f695672fecf8331f4706 commit ccf50c1df9cf1379e337f695672fecf8331f4706 Author: Wolfram Schneider <wosch@FreeBSD.org> AuthorDate: 2022-01-25 16:55:58 +0000 Commit: Wolfram Schneider <wosch@FreeBSD.org> CommitDate: 2022-01-25 16:55:58 +0000 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 67d22bfca7b7..7340ce156675 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_ */