Migrate from using MAXPATHLEN to MAX_PATH. Use strlcpy to copy the
strings.
This commit is contained in:
parent
aecd12aed8
commit
34f9c106b9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=76693
@ -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;
|
||||
|
@ -37,7 +37,7 @@
|
||||
typedef struct {
|
||||
char *p_end; /* pointer to NULL at end of path */
|
||||
char *target_end; /* pointer to end of target base */
|
||||
char p_path[MAXPATHLEN + 1]; /* pointer to the start of a path */
|
||||
char p_path[PATH_MAX]; /* pointer to the start of a path */
|
||||
} PATH_T;
|
||||
|
||||
extern PATH_T to;
|
||||
|
@ -50,6 +50,7 @@ static const char rcsid[] =
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fts.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
@ -209,7 +210,7 @@ copy_link(p, exists)
|
||||
int exists;
|
||||
{
|
||||
int len;
|
||||
char link[MAXPATHLEN];
|
||||
char link[PATH_MAX];
|
||||
|
||||
if ((len = readlink(p->fts_path, link, sizeof(link) - 1)) == -1) {
|
||||
warn("readlink: %s", p->fts_path);
|
||||
|
Loading…
Reference in New Issue
Block a user