diff options
Diffstat (limited to 'ln.c')
-rw-r--r-- | ln.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -30,7 +30,6 @@ | |||
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | #include <dirent.h> | 31 | #include <dirent.h> |
32 | #include <errno.h> | 32 | #include <errno.h> |
33 | #include <sys/param.h> /* for PATH_MAX */ | ||
34 | 33 | ||
35 | static const char ln_usage[] = | 34 | static const char ln_usage[] = |
36 | "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n" | 35 | "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n" |
@@ -78,7 +77,7 @@ extern int ln_main(int argc, char **argv) | |||
78 | 77 | ||
79 | linkName = argv[argc - 1]; | 78 | linkName = argv[argc - 1]; |
80 | 79 | ||
81 | if (strlen(linkName) > PATH_MAX) { | 80 | if (strlen(linkName) > BUFSIZ) { |
82 | fprintf(stderr, name_too_long, "ln"); | 81 | fprintf(stderr, name_too_long, "ln"); |
83 | exit FALSE; | 82 | exit FALSE; |
84 | } | 83 | } |
@@ -91,10 +90,10 @@ extern int ln_main(int argc, char **argv) | |||
91 | } | 90 | } |
92 | 91 | ||
93 | while (argc-- >= 2) { | 92 | while (argc-- >= 2) { |
94 | char srcName[PATH_MAX + 1]; | 93 | char srcName[BUFSIZ + 1]; |
95 | int nChars, status; | 94 | int nChars, status; |
96 | 95 | ||
97 | if (strlen(*argv) > PATH_MAX) { | 96 | if (strlen(*argv) > BUFSIZ) { |
98 | fprintf(stderr, name_too_long, "ln"); | 97 | fprintf(stderr, name_too_long, "ln"); |
99 | exit FALSE; | 98 | exit FALSE; |
100 | } | 99 | } |
@@ -102,9 +101,9 @@ extern int ln_main(int argc, char **argv) | |||
102 | if (followLinks == FALSE) { | 101 | if (followLinks == FALSE) { |
103 | strcpy(srcName, *argv); | 102 | strcpy(srcName, *argv); |
104 | } else { | 103 | } else { |
105 | /* Warning! This can silently truncate if > PATH_MAX, but | 104 | /* Warning! This can silently truncate if > BUFSIZ, but |
106 | I don't think that there can be one > PATH_MAX anyway. */ | 105 | I don't think that there can be one > BUFSIZ anyway. */ |
107 | nChars = readlink(*argv, srcName, PATH_MAX); | 106 | nChars = readlink(*argv, srcName, BUFSIZ); |
108 | srcName[nChars] = '\0'; | 107 | srcName[nChars] = '\0'; |
109 | } | 108 | } |
110 | 109 | ||