don't pass NULL as the 2nd arg to getcwd(), ala lib/path.c.
fixes 'pkg_admin lsall' and 'pkg_admin lsbest' on Solaris and probably other platforms where getcwd() doesn't allocate a buffer when the 2nd arg is NULL. ok'd by simonb@
This commit is contained in:
parent
2807f6e56a
commit
5cea86225d
|
@ -1,8 +1,8 @@
|
|||
/* $NetBSD: main.c,v 1.34 2003/03/24 21:44:45 seb Exp $ */
|
||||
/* $NetBSD: main.c,v 1.35 2003/04/17 13:32:21 grant Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: main.c,v 1.34 2003/03/24 21:44:45 seb Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.35 2003/04/17 13:32:21 grant Exp $");
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -442,7 +442,7 @@ main(int argc, char *argv[])
|
|||
/* args specified */
|
||||
int rc;
|
||||
const char *basep, *dir;
|
||||
char *cwd;
|
||||
char cwd[MAXPATHLEN];
|
||||
char base[FILENAME_MAX];
|
||||
|
||||
dir = dirname_of(*argv);
|
||||
|
@ -454,11 +454,11 @@ main(int argc, char *argv[])
|
|||
if (rc == -1)
|
||||
err(EXIT_FAILURE, "Cannot chdir to %s", _pkgdb_getPKGDB_DIR());
|
||||
|
||||
cwd = getcwd(NULL, 0);
|
||||
if (getcwd(cwd, sizeof(cwd)) == NULL)
|
||||
err(EXIT_FAILURE, "getcwd");
|
||||
if (findmatchingname(cwd, base, lspattern_fn, cwd) == -1)
|
||||
errx(EXIT_FAILURE, "Error in findmatchingname(\"%s\", \"%s\", ...)",
|
||||
cwd, base);
|
||||
free(cwd);
|
||||
|
||||
argv++;
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ main(int argc, char *argv[])
|
|||
/* args specified */
|
||||
int rc;
|
||||
const char *basep, *dir;
|
||||
char *cwd;
|
||||
char cwd[MAXPATHLEN];
|
||||
char base[FILENAME_MAX];
|
||||
char *p;
|
||||
|
||||
|
@ -493,13 +493,13 @@ main(int argc, char *argv[])
|
|||
if (rc == -1)
|
||||
err(EXIT_FAILURE, "Cannot chdir to %s", _pkgdb_getPKGDB_DIR());
|
||||
|
||||
cwd = getcwd(NULL, 0);
|
||||
if (getcwd(cwd, sizeof(cwd)) == NULL)
|
||||
err(EXIT_FAILURE, "getcwd");
|
||||
p = findbestmatchingname(cwd, base);
|
||||
if (p) {
|
||||
printf("%s/%s\n", cwd, p);
|
||||
free(p);
|
||||
}
|
||||
free(cwd);
|
||||
|
||||
argv++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue