Fix file corruption when copying dirs to A:/

thanks @ihaveamac for pointing this one out.
This commit is contained in:
d0k3 2018-03-16 18:46:53 +01:00
parent ac514669a1
commit 07b06b8552

View File

@ -487,10 +487,9 @@ bool PathMoveCopyRec(char* dest, char* orig, u32* flags, bool move, u8* buffer,
char* oname = strrchr(orig, '/'); char* oname = strrchr(orig, '/');
char* dname = dest + strnlen(dest, 255); char* dname = dest + strnlen(dest, 255);
if (oname == NULL) return false; // not a proper origin path if (oname == NULL) return false; // not a proper origin path
*(dname++) = '/'; strncpy(dname, oname, 256 - (dname - dest)); // copy name plus preceding '/'
strncpy(dname, oname++, 256 - (dname - dest));
bool res = PathMoveCopyRec(dest, orig, flags, move, buffer, bufsiz); bool res = PathMoveCopyRec(dest, orig, flags, move, buffer, bufsiz);
*(--dname) = '\0'; *dname = '\0';
if (!res) break; if (!res) break;
} }
} }