From 4b34c18e99216a00deff17245442e1ff27cf257c Mon Sep 17 00:00:00 2001 From: shinyquagsire23 Date: Mon, 8 Aug 2016 11:56:41 -0700 Subject: [PATCH] Fix ENAMETOOLONG handling, write buffer size in devoptab --- rpl/libcoreinit/fs_dev.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/rpl/libcoreinit/fs_dev.c b/rpl/libcoreinit/fs_dev.c index 7c033b9..45f7aa3 100644 --- a/rpl/libcoreinit/fs_dev.c +++ b/rpl/libcoreinit/fs_dev.c @@ -179,25 +179,25 @@ fs_fixpath(struct _reent *r, const char *path) { char *p = strchr(path, ':')+1; + + if(!strchr(path, ':')) { + p = (char*)path; + } + + if (strlen(p) > PATH_MAX) { + r->_errno = ENAMETOOLONG; + return NULL; + } + char *__fixedpath = memalign(0x40, PATH_MAX+1); if (__fixedpath == NULL) { return NULL; } - if(!strchr(path, ':')) { - p = (char*)path; - } - // cwd is handled by coreinit, so just strip the 'fs:' if it exists strcpy(__fixedpath, p); - if (__fixedpath[PATH_MAX] != 0) { - __fixedpath[PATH_MAX] = 0; - r->_errno = ENAMETOOLONG; - return NULL; - } - return __fixedpath; } @@ -331,8 +331,8 @@ fs_write(struct _reent *r, while(len > 0) { size_t toWrite = len; - if (toWrite > sizeof(tmp_buffer)) { - toWrite = sizeof(tmp_buffer); + if (toWrite > 8192) { + toWrite = 8192; } // Copy to internal buffer @@ -387,8 +387,8 @@ fs_write_safe(struct _reent *r, while(len > 0) { size_t toWrite = len; - if (toWrite > sizeof(tmp_buffer)) { - toWrite = sizeof(tmp_buffer); + if (toWrite > 8192) { + toWrite = 8192; } // Copy to internal buffer