Fix ENAMETOOLONG handling, write buffer size in devoptab

This commit is contained in:
shinyquagsire23 2016-08-08 11:56:41 -07:00
parent b41ae7993c
commit 4b34c18e99

View File

@ -179,25 +179,25 @@ fs_fixpath(struct _reent *r,
const char *path) const char *path)
{ {
char *p = strchr(path, ':')+1; 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); char *__fixedpath = memalign(0x40, PATH_MAX+1);
if (__fixedpath == NULL) { if (__fixedpath == NULL) {
return NULL; return NULL;
} }
if(!strchr(path, ':')) {
p = (char*)path;
}
// cwd is handled by coreinit, so just strip the 'fs:' if it exists // cwd is handled by coreinit, so just strip the 'fs:' if it exists
strcpy(__fixedpath, p); strcpy(__fixedpath, p);
if (__fixedpath[PATH_MAX] != 0) {
__fixedpath[PATH_MAX] = 0;
r->_errno = ENAMETOOLONG;
return NULL;
}
return __fixedpath; return __fixedpath;
} }
@ -331,8 +331,8 @@ fs_write(struct _reent *r,
while(len > 0) { while(len > 0) {
size_t toWrite = len; size_t toWrite = len;
if (toWrite > sizeof(tmp_buffer)) { if (toWrite > 8192) {
toWrite = sizeof(tmp_buffer); toWrite = 8192;
} }
// Copy to internal buffer // Copy to internal buffer
@ -387,8 +387,8 @@ fs_write_safe(struct _reent *r,
while(len > 0) { while(len > 0) {
size_t toWrite = len; size_t toWrite = len;
if (toWrite > sizeof(tmp_buffer)) { if (toWrite > 8192) {
toWrite = sizeof(tmp_buffer); toWrite = 8192;
} }
// Copy to internal buffer // Copy to internal buffer