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
This commit is contained in:
parent
36f0a34ca6
commit
f4613af424
|
@ -717,12 +717,9 @@ read_kld(char *filename, char *kldname)
|
||||||
static FILE *
|
static FILE *
|
||||||
maketempfile(char *dest, const char *root)
|
maketempfile(char *dest, const char *root)
|
||||||
{
|
{
|
||||||
char *p;
|
int fd;
|
||||||
int n, fd;
|
|
||||||
|
|
||||||
p = strrchr(root, '/');
|
if (snprintf(dest, MAXPATHLEN, "%s/lhint.XXXXXX", root) >=
|
||||||
n = p != NULL ? p - root + 1 : 0;
|
|
||||||
if (snprintf(dest, MAXPATHLEN, "%.*slhint.XXXXXX", n, root) >=
|
|
||||||
MAXPATHLEN) {
|
MAXPATHLEN) {
|
||||||
errno = ENAMETOOLONG;
|
errno = ENAMETOOLONG;
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
Loading…
Reference in New Issue