Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Feb 2024 15:52:23 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f4613af424cc - main - kldxref: Fix maketempfile function's way of finding the root dir
Message-ID:  <202402021552.412FqN96034033@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=f4613af424cc93d42f35730fd9862f0c6f964cbd

commit f4613af424cc93d42f35730fd9862f0c6f964cbd
Author:     Mina Galić <freebsd@igalic.co>
AuthorDate: 2024-02-02 15:35:46 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-02-02 15:35:49 +0000

    kldxref: Fix maketempfile function's way of finding the root dir
    
    Rather than assuming that the "root" is passed as directory and will be
    marked by a trailing slash, we just assume that the directory, which has
    been checked previously to be a directory, is a directory.
    
    This fixes an inconsistency between `kldxref /boot/modules`, which tries
    to create the temp file in `/boot/`, and `kldxref /boot/modules/`, which
    tries to create it in `/boot/modules/` itself.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1093
---
 usr.sbin/kldxref/kldxref.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/usr.sbin/kldxref/kldxref.c b/usr.sbin/kldxref/kldxref.c
index 1f06ad811d91..969d07e5677a 100644
--- a/usr.sbin/kldxref/kldxref.c
+++ b/usr.sbin/kldxref/kldxref.c
@@ -717,12 +717,9 @@ read_kld(char *filename, char *kldname)
 static FILE *
 maketempfile(char *dest, const char *root)
 {
-	char *p;
-	int n, fd;
+	int fd;
 
-	p = strrchr(root, '/');
-	n = p != NULL ? p - root + 1 : 0;
-	if (snprintf(dest, MAXPATHLEN, "%.*slhint.XXXXXX", n, root) >=
+	if (snprintf(dest, MAXPATHLEN, "%s/lhint.XXXXXX", root) >=
 	    MAXPATHLEN) {
 		errno = ENAMETOOLONG;
 		return (NULL);



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