diff options
author | imp <imp@FreeBSD.org> | 2001-05-16 19:10:40 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2001-05-16 19:10:40 +0000 |
commit | d3f66389ff16a4744bbf881cad06556b1b9830fe (patch) | |
tree | b04dfa3212484d6d0559a8715c17cf27319f27bb /bin/cp/cp.c | |
parent | e2fa665e9f1748f3f8e15f524f6d7fb542e66b37 (diff) | |
download | FreeBSD-src-d3f66389ff16a4744bbf881cad06556b1b9830fe.zip FreeBSD-src-d3f66389ff16a4744bbf881cad06556b1b9830fe.tar.gz |
Migrate from using MAXPATHLEN to MAX_PATH. Use strlcpy to copy the
strings.
Diffstat (limited to 'bin/cp/cp.c')
-rw-r--r-- | bin/cp/cp.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c index e528aea..0592444 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -69,6 +69,7 @@ static const char rcsid[] = #include <err.h> #include <errno.h> #include <fts.h> +#include <limits.h> #include <stdio.h> #include <string.h> #include <unistd.h> @@ -177,9 +178,8 @@ main(argc, argv) /* Save the target base in "to". */ target = argv[--argc]; - if (strlen(target) > MAXPATHLEN) + if (strlcpy(to.p_path, target, sizeof(to.p_path)) >= sizeof(to.p_path)) errx(1, "%s: name too long", target); - (void)strcpy(to.p_path, target); to.p_end = to.p_path + strlen(to.p_path); if (to.p_path == to.p_end) { *to.p_end++ = '.'; @@ -318,7 +318,7 @@ copy(argv, type, fts_options) if (*p != '/' && target_mid[-1] != '/') *target_mid++ = '/'; *target_mid = 0; - if (target_mid - to.p_path + nlen > MAXPATHLEN) { + if (target_mid - to.p_path + nlen >= PATH_MAX) { warnx("%s%s: name too long (not copied)", to.p_path, p); badcp = rval = 1; |