archive_dev: Ensure path separator for local path (#524)

Fixes issue where fopen("test.txt","r") opens 3dstest.txt instead of test.txt.

Also correct misuse of strncat() as count applies to src not dest.

See:
8136d94657
806a4d34c5
This commit is contained in:
oreo639 2023-05-07 04:08:13 -07:00 committed by GitHub
parent 8d90551306
commit 39a53c4fe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,9 +205,11 @@ archive_fixpath(struct _reent *r,
strncpy(__ctru_dev_path_buf, path, PATH_MAX);
else
{
size_t cwdlen = strlen(dev->cwd);
strncpy(__ctru_dev_path_buf, dev->cwd, PATH_MAX);
__ctru_dev_path_buf[PATH_MAX] = '\0';
strncat(__ctru_dev_path_buf, path, PATH_MAX);
strncat(__ctru_dev_path_buf, "/", PATH_MAX - cwdlen);
strncat(__ctru_dev_path_buf, path, PATH_MAX - cwdlen - 1);
}
if(__ctru_dev_path_buf[PATH_MAX] != 0)