From nobody Mon Jan 31 17:36:19 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BABF01989531; Mon, 31 Jan 2022 17:36:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JnZwz4r5gz4TjB; Mon, 31 Jan 2022 17:36:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643650579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wY1bfYdDqktD3zKMBJVqkrkf29rRWUsCKdrlH8YG2vc=; b=Io98WRnmtxQq52ZzgFIT6VgzjwDsdj7TpdnbiZ9x3zWjGj/t/LlFprVVDbCjy5WVzEZteW jH/+QmJKwflPfUrbc/Sr4anQ7LvGeYOZlcu5DD7lVG+9ofrV+6RioIFi3JE6MQrlXgKLpy 5BggWcVLLNbsak0hajJveJ6D+Vo33+Jnmnc+13j++Oe+kk41vYVeNrrHc3ApS8RGYt86y2 vWmppgRwJiFSkUWhb/dDiACqk1FwlTb4O8qGDuubBjv0fpxVUDmJP7vxGtT/aoZfHrbBCd OPiZ/8z5YNs9lQqLz4j9BPWC5Az1ieG2ygky4w7+DpDaOn6KL8HQMJOw9MQ+MA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7B85B206C9; Mon, 31 Jan 2022 17:36:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20VHaJU4096310; Mon, 31 Jan 2022 17:36:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20VHaJ8c096309; Mon, 31 Jan 2022 17:36:19 GMT (envelope-from git) Date: Mon, 31 Jan 2022 17:36:19 GMT Message-Id: <202201311736.20VHaJ8c096309@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wolfram Schneider Subject: git: 834a8fa1694d - main - enable to configure the locate path length at compile time List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wosch X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 834a8fa1694db39a356f1732d78f39ff76da422c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643650579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wY1bfYdDqktD3zKMBJVqkrkf29rRWUsCKdrlH8YG2vc=; b=hnv2gxrZ3KAoTdNQMEDrOIJCO/Qyyz62w6NUnMhXBtITZ7dbHseuiSho3zHq772mVhiEdq F1daVsQgJ/MtLi0+PqL3Q0Qz0t9JnQ7J/StfO46/wClkBZ4cMm2MTt7NIZzLltNkFNt/Ho l5styoKAa9EVCDtseXtHg07r5vaD0GlWhm88onUgUGCinRbdEUUznxc6QBMWN0b2nlQzY8 9XF34Y+3NiPOxET6UTynz3KnxvhLg4aBNUvNFRff/G9aKotYpthQ9nbl2XaxdqtkYhLEia vvN48+gdOeKIYbTgjK6a4iBqTiBfMvhdOe+SkeXakbLAUWinv2/BdFmc0/BCJw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643650579; a=rsa-sha256; cv=none; b=BIXYQ7dE+LE81sKfjvSLkfxKlOhRhWdKhzN4anNVl+YzjDoXg3Z2EjL9rhr0QkCOD+bbtX 0mprHeaKyeW+3EdCdmFmffBPaSr+mq7fC8pQME68kqD5WqMnAx0lvbrUyECGPuBgwnLqDg 89KmjYTVAiGDM7TKfznhv9kX11Hex0n7rswpapBDWSHOyH8sTrOPwMyfIs4kEkl7i/jExA A2fHNQldGKyvnD6WHVZgDt/fbpKzJrbVED1fDJFOHnj6AavIGQ7fRrKwT2WmBuJfV9rZvM BDJzjeMztO70V13gAtc/avhYMrQbM14gWNfCA3wBX+hSqW66OFs3BKos8TQB+A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wosch: URL: https://cgit.FreeBSD.org/src/commit/?id=834a8fa1694db39a356f1732d78f39ff76da422c commit 834a8fa1694db39a356f1732d78f39ff76da422c Author: Wolfram Schneider AuthorDate: 2022-01-31 17:32:46 +0000 Commit: Wolfram Schneider CommitDate: 2022-01-31 17:32:46 +0000 enable to configure the locate path length at compile time The length has not changed and is 1024 chars (equals PATH_MAX). PR: 201243 Submitted by: Willem Jan Withagen --- usr.bin/locate/bigram/locate.bigram.c | 5 ++--- usr.bin/locate/code/locate.code.c | 6 +++--- usr.bin/locate/locate/fastfind.c | 14 +++++++------- usr.bin/locate/locate/locate.h | 6 ++++++ usr.bin/locate/locate/util.c | 11 +++++------ 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/usr.bin/locate/bigram/locate.bigram.c b/usr.bin/locate/bigram/locate.bigram.c index d15f8ce170e8..a654448680a3 100644 --- a/usr.bin/locate/bigram/locate.bigram.c +++ b/usr.bin/locate/bigram/locate.bigram.c @@ -59,11 +59,10 @@ static char sccsid[] = "@(#)locate.bigram.c 8.1 (Berkeley) 6/6/93"; #include #include #include -#include /* for MAXPATHLEN */ #include "locate.h" -u_char buf1[MAXPATHLEN] = " "; -u_char buf2[MAXPATHLEN]; +u_char buf1[LOCATE_PATH_MAX] = " "; +u_char buf2[LOCATE_PATH_MAX]; unsigned long bigram[UCHAR_MAX + 1][UCHAR_MAX + 1]; int diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c index 9da78d55e622..5263d9ee8fb0 100644 --- a/usr.bin/locate/code/locate.code.c +++ b/usr.bin/locate/code/locate.code.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 1995 Wolfram Schneider . Berlin. + * Copyright (c) 1995-2022 Wolfram Schneider * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * @@ -102,8 +102,8 @@ static char sccsid[] = "@(#)locate.code.c 8.1 (Berkeley) 6/6/93"; #define BGBUFSIZE (NBG * 2) /* size of bigram buffer */ -u_char buf1[MAXPATHLEN] = " "; -u_char buf2[MAXPATHLEN]; +u_char buf1[LOCATE_PATH_MAX] = " "; +u_char buf2[LOCATE_PATH_MAX]; u_char bigrams[BGBUFSIZE + 1] = { 0 }; #define LOOKUP 1 /* use a lookup array instead a function, 3x faster */ diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c index 9a3324e20e44..8cc9af924531 100644 --- a/usr.bin/locate/locate/fastfind.c +++ b/usr.bin/locate/locate/fastfind.c @@ -49,7 +49,7 @@ statistic (fp, path_fcodes) int c; int count, longest_path; int error = 0; - u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN]; + u_char bigram1[NBG], bigram2[NBG], path[LOCATE_PATH_MAX]; for (c = 0, p = bigram1, s = bigram2; c < NBG; c++) { p[c] = check_bigram_char(getc(fp)); @@ -67,9 +67,9 @@ statistic (fp, path_fcodes) } else count += c - OFFSET; - if (count < 0 || count >= MAXPATHLEN) { + if (count < 0 || count >= LOCATE_PATH_MAX) { /* stop on error and display the statstics anyway */ - warnx("corrupted database: %s", path_fcodes); + warnx("corrupted database: %s %d", path_fcodes, count); error = 1; break; } @@ -157,7 +157,7 @@ fastfind int c, cc; int count, found, globflag; u_char *cutoff; - u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN + 2]; + u_char bigram1[NBG], bigram2[NBG], path[LOCATE_PATH_MAX + 2]; #ifdef FF_ICASE /* use a lookup table for case insensitive search */ @@ -233,7 +233,7 @@ fastfind count += c - OFFSET; } - if (count < 0 || count >= MAXPATHLEN) + if (count < 0 || count >= LOCATE_PATH_MAX) errx(1, "corrupted database: %s %d", database, count); /* overlay old path */ @@ -295,8 +295,8 @@ fastfind *p++ = bigram2[c]; } - if (p - path >= MAXPATHLEN) - errx(1, "corrupted database: %s", database); + if (p - path >= LOCATE_PATH_MAX) + errx(1, "corrupted database: %s %ld", database, p - path); } diff --git a/usr.bin/locate/locate/locate.h b/usr.bin/locate/locate/locate.h index 6393160d55b4..18187ca00d84 100644 --- a/usr.bin/locate/locate/locate.h +++ b/usr.bin/locate/locate/locate.h @@ -68,3 +68,9 @@ extern u_char myctype[UCHAR_MAX + 1]; #define INTSIZE (sizeof(int)) #define LOCATE_REG "*?[]\\" /* fnmatch(3) meta characters */ + +/* max. path length for locate. Should be at least 1024 (PATH_MAX), but can be longer */ +#ifndef LOCATE_PATH_MAX +#define LOCATE_PATH_MAX (1*1024) +#endif + diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c index 8482ec998f03..1d15f83b6826 100644 --- a/usr.bin/locate/locate/util.c +++ b/usr.bin/locate/locate/util.c @@ -35,11 +35,10 @@ * $FreeBSD$ */ - +#include #include #include #include -#include #include #include @@ -224,8 +223,8 @@ getwm(p) int i, hi; /* the integer is stored by an offset of 14 (!!!) */ - int i_max = MAXPATHLEN + OFFSET; - int i_min = -(MAXPATHLEN - OFFSET); + int i_max = LOCATE_PATH_MAX + OFFSET; + int i_min = -(LOCATE_PATH_MAX - OFFSET); for (i = 0; i < (int)INTSIZE; i++) u.buf[i] = *p++; @@ -255,8 +254,8 @@ getwf(fp) FILE *fp; { int word, hword; - int i_max = MAXPATHLEN + OFFSET; - int i_min = -(MAXPATHLEN - OFFSET); + int i_max = LOCATE_PATH_MAX + OFFSET; + int i_min = -(LOCATE_PATH_MAX - OFFSET); word = getw(fp);