Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/pkg_install/admin don't pass NULL as the 2nd arg to...
details: https://anonhg.NetBSD.org/src/rev/8a51e7e13780
branches: trunk
changeset: 545889:8a51e7e13780
user: grant <grant%NetBSD.org@localhost>
date: Thu Apr 17 13:32:21 2003 +0000
description:
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@
diffstat:
usr.sbin/pkg_install/admin/main.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diffs (64 lines):
diff -r 841e3fb29f12 -r 8a51e7e13780 usr.sbin/pkg_install/admin/main.c
--- a/usr.sbin/pkg_install/admin/main.c Thu Apr 17 13:12:39 2003 +0000
+++ b/usr.sbin/pkg_install/admin/main.c Thu Apr 17 13:32:21 2003 +0000
@@ -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 @@
/* args specified */
int rc;
const char *basep, *dir;
- char *cwd;
+ char cwd[MAXPATHLEN];
char base[FILENAME_MAX];
dir = dirname_of(*argv);
@@ -454,12 +454,12 @@
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 @@
/* args specified */
int rc;
const char *basep, *dir;
- char *cwd;
+ char cwd[MAXPATHLEN];
char base[FILENAME_MAX];
char *p;
@@ -493,13 +493,13 @@
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++;
}
Home |
Main Index |
Thread Index |
Old Index