- use MAXPATHLEN per realpath(3)
- use the problematic part of the path, instead of the argument, when reporting an error. Reviewed by: mike
This commit is contained in:
parent
0c21294cee
commit
9a26e46eb4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108032
@ -46,7 +46,7 @@ static void usage(void) __dead2;
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[MAXPATHLEN];
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
@ -54,7 +54,7 @@ main(int argc, char *argv[])
|
|||||||
err(1, "getcwd()");
|
err(1, "getcwd()");
|
||||||
} else if (argc == 2) {
|
} else if (argc == 2) {
|
||||||
if ((p = realpath(argv[1], buf)) == NULL)
|
if ((p = realpath(argv[1], buf)) == NULL)
|
||||||
err(1, "%s", argv[1]);
|
err(1, "%s", buf);
|
||||||
} else
|
} else
|
||||||
usage();
|
usage();
|
||||||
(void)printf("%s\n", p);
|
(void)printf("%s\n", p);
|
||||||
|
Loading…
Reference in New Issue
Block a user