* path.cc (path_conv::path_conv): Ensure that suffix is correctly copied to

path when we've found a symlink but aren't following symlinks.
This commit is contained in:
Christopher Faylor 2000-04-12 22:50:08 +00:00
parent d13dac7f30
commit 0d60da2632
2 changed files with 24 additions and 18 deletions

View File

@ -1,3 +1,9 @@
Wed Apr 12 18:48:33 2000 Christopher Faylor <cgf@cygnus.com>
* path.cc (path_conv::path_conv): Ensure that suffix is correctly
copied to path when we've found a symlink but aren't following
symlinks.
Sat Apr 8 00:46:14 2000 Christopher Faylor <cgf@cygnus.com> Sat Apr 8 00:46:14 2000 Christopher Faylor <cgf@cygnus.com>
* fhandler.cc (fhandler_disk_file::fstat): Allocate enough space for * fhandler.cc (fhandler_disk_file::fstat): Allocate enough space for

View File

@ -184,8 +184,8 @@ path_conv::path_conv (const char *src, symlink_follow follow_mode,
in length so that we can hold the expanded symlink plus a in length so that we can hold the expanded symlink plus a
trailer. */ trailer. */
char work_buf[MAX_PATH * 3 + 3]; char work_buf[MAX_PATH * 3 + 3];
char tmp_buf[MAX_PATH];
char path_buf[MAX_PATH]; char path_buf[MAX_PATH];
char path_copy[MAX_PATH];
char *rel_path, *full_path; char *rel_path, *full_path;
@ -237,7 +237,6 @@ path_conv::path_conv (const char *src, symlink_follow follow_mode,
} }
/* Make a copy of the path that we can munge up */ /* Make a copy of the path that we can munge up */
char path_copy[strlen (full_path) + 2];
strcpy (path_copy, full_path); strcpy (path_copy, full_path);
tail = path_copy + 1 + (tail - full_path); // Point to end of copy tail = path_copy + 1 + (tail - full_path); // Point to end of copy
@ -285,13 +284,6 @@ path_conv::path_conv (const char *src, symlink_follow follow_mode,
fileattr = attr; fileattr = attr;
if (follow_mode == SYMLINK_CONTENTS) if (follow_mode == SYMLINK_CONTENTS)
goto out; goto out;
else if (*sym_buf)
{
known_suffix = strchr (this->path, '\0');
strcpy (known_suffix, sym_buf);
}
else if (known_suffix)
known_suffix = this->path + (known_suffix - path_copy);
} }
goto out; // file found goto out; // file found
} }
@ -302,16 +294,13 @@ path_conv::path_conv (const char *src, symlink_follow follow_mode,
these operations again on the newly derived path. */ these operations again on the newly derived path. */
else if (len > 0) else if (len > 0)
{ {
if (component == 0) if (component != 0 && follow_mode != SYMLINK_FOLLOW)
{ {
if (follow_mode != SYMLINK_FOLLOW) set_symlink (); // last component of path is a symlink.
{ fileattr = attr;
set_symlink (); // last component of path's a symlink. if (follow_mode == SYMLINK_CONTENTS)
fileattr = attr; strcpy (path, sym_buf);
if (follow_mode == SYMLINK_CONTENTS) goto found_symlink;
strcpy (path, sym_buf);
goto out;
}
} }
break; break;
} }
@ -362,6 +351,7 @@ path_conv::path_conv (const char *src, symlink_follow follow_mode,
system_printf ("problem parsing %s - '%s'", src, full_path); system_printf ("problem parsing %s - '%s'", src, full_path);
else else
{ {
char tmp_buf[MAX_PATH];
int headlen = 1 + tail - path_copy; int headlen = 1 + tail - path_copy;
p = sym_buf - headlen; p = sym_buf - headlen;
memcpy (p, path_copy, headlen); memcpy (p, path_copy, headlen);
@ -373,6 +363,16 @@ path_conv::path_conv (const char *src, symlink_follow follow_mode,
src = tmp_buf; src = tmp_buf;
} }
} }
found_symlink:
if (*sym_buf)
{
known_suffix = strchr (this->path, '\0');
strcpy (known_suffix, sym_buf);
}
else if (known_suffix)
known_suffix = this->path + (known_suffix - path_copy);
out: out:
DWORD serial, volflags; DWORD serial, volflags;