Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Jan 2022 16:57:25 GMT
From:      Wolfram Schneider <wosch@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ccf50c1df9cf - main - locate statistics: non zero exit on corrupt database
Message-ID:  <202201251657.20PGvPWP074537@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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_ */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201251657.20PGvPWP074537>