Jinoh Kang (@iamahuman) commented about server/fd.c:
((fd->options & FILE_DELETE_ON_CLOSE) ? FILE_DISPOSITION_DELETE : 0);
}
+/* rename the same file, dealing with casefolding and possibly different hardlinks to it */ +static void rename_same_file( const char *src, const char *dst, int is_dir ) +{
- static const char tmpname_fmt[] = ".wine-rename-tmp-%08x";
- static unsigned tmp_value;
- char *dirname, tmpname[sizeof(tmpname_fmt) + 4 /* remaining of %08x */];
- const char *srcname, *dstname = strrchr( dst, '/' ) + 1;
- struct stat st, st2;
- int dirfd, res = 0;
- unsigned i;
You should check for `"/"`; otherwise dstname will be empty and `MoveFile( "\??\unix\", "\??\unix\" )` fails with a cryptic error `ERROR_FILE_NOT_FOUND`. Also, move `dstname` assignment below the / check where we have guaranteed that dst is not `"/"`:
```suggestion:-0+0
if (!strcmp( src, "/" ) || !strcmp( dst, "/" )) { set_error( STATUS_ACCESS_DENIED ); return; }
dstname = strrchr( dst, '/' ) + 1; ```