stat_result = lstat (link_file_name, &stat_buf);
if (stat_result == 0 && (stat_buf.st_mode & S_IFMT) == S_IFLNK)
{
- while ((link_len = readlink(link_file_name, link_path, MAX_PATH)) > 0)
+ while ((link_len = readlink(link_file_name, link_path, MAX_PATH - 1)) > 0)
{
- link_path[link_len] = '\0';
+ link_path[link_len] = 0;
link_list = (char **)XtRealloc((char *)link_list, sizeof(char *) *
(link_count + 2));
stat_result = lstat (link_file_name, &stat_buf);
if ((stat_buf.st_mode & S_IFMT) == S_IFLNK)
{
- while ((link_len = readlink(link_file_name, link_path, MAX_PATH)) > 0)
+ while ((link_len = readlink(link_file_name, link_path, MAX_PATH - 1)) > 0)
{
- link_path[link_len] = NILL;
+ link_path[link_len] = 0;
link_list = (char **)XtRealloc((char *)link_list, sizeof(char *) *
(link_count + 2));
strcpy(file, path);
- while ((link_len = readlink(file, link_path, MAXPATHLEN)) > 0)
+ while ((link_len = readlink(file, link_path, MAXPATHLEN - 1)) > 0)
{
- link_path[link_len] = '\0';
+ link_path[link_len] = 0;
/* Force the link to be an absolute path, if necessary */
if (link_path[0] != '/')
/* copy a symbolic link */
{
int l, rc;
- char buf[1024];
+ char buf[PATH_MAX];
do {
errno = 0;
- l = readlink(sourceP, buf, sizeof(buf));
+ l = readlink(sourceP, buf, PATH_MAX - 1);
} while (l < 0 && errno == EINTR);
+
if (l < 0)
return errno;
+
buf[l] = 0;
+
if (symlink(buf, targetP) == 0)
return 0;
else if (errno != EEXIST || !repl)