Returns true if this pathname is within the share, and thus safe.
****************************************************************************/
-static int ensure_link_is_safe(connection_struct *conn, const char *link_dest_in, char *link_dest_out)
+static int ensure_link_is_safe(connection_struct *conn, const char *link_dest_in)
{
#ifdef PATH_MAX
char resolved_name[PATH_MAX+1];
pstrcpy(link_dest, link_dest_in);
unix_convert(link_dest,conn,0,&bad_path,&sbuf);
- /* Store the UNIX converted path. */
- pstrcpy(link_dest_out, link_dest);
-
p = strrchr_m(link_dest, '/');
if (p) {
fstrcpy(last_component, p+1);
return NT_STATUS_FILE_IS_A_DIRECTORY;
}
- if (ensure_link_is_safe(conn, oldname, oldname) != 0)
+ /* Ensure this is within the share. */
+ if (!reduce_name(conn, oldname) != 0)
return NT_STATUS_ACCESS_DENIED;
DEBUG(10,("hardlink_internals: doing hard link %s -> %s\n", newname, oldname ));
pstrcpy(rel_name, "./");
}
pstrcat(rel_name, link_target);
- if (ensure_link_is_safe(conn, rel_name, rel_name) != 0) {
+ if (ensure_link_is_safe(conn, rel_name) != 0) {
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
if (p) {
*p++ = '\0';
fstrcpy(last_component, p);
+ } else {
+ fstrcpy(last_component, tmp_fname);
+ pstrcpy(tmp_fname, ".");
}
+
#ifdef REALPATH_TAKES_NULL
resolved_name = SMB_VFS_REALPATH(conn,tmp_fname,NULL);
#else