improve validation errors

This commit is contained in:
rumbledethumps
2025-04-27 23:52:23 -07:00
parent 5cb1bc60fc
commit 34bb14bc6e
6 changed files with 10 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
#include <rp6502.h>
#include <errno.h>
#include <fcntl.h>
int __fastcall__ close (int fd)
{

View File

@@ -1,12 +1,14 @@
#include <rp6502.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
int __cdecl__ open (const char* name, int flags, ...)
{
size_t namelen = strlen (name);
if (namelen > 255) {
return _mappederrno (EINVAL);
RIA.errno = EINVAL;
return _mappederrno(RIA.errno);
}
while (namelen) {
ria_push_char (name[--namelen]);

View File

@@ -1,4 +1,3 @@
#include <rp6502.h>
int __fastcall__ stdin_opt (unsigned long ctrl_bits, unsigned char str_length)

View File

@@ -7,7 +7,8 @@ unsigned char __fastcall__ _sysremove (const char* name)
size_t namelen;
namelen = strlen (name);
if (namelen > 255) {
return _mappederrno (EINVAL);
RIA.errno = EINVAL;
return __mappederrno(RIA.errno);
}
while (namelen) {
ria_push_char (name[--namelen]);

View File

@@ -8,7 +8,8 @@ unsigned char __fastcall__ _sysrename (const char* oldpath, const char* newpath)
oldpathlen = strlen (oldpath);
newpathlen = strlen (newpath);
if (oldpathlen + newpathlen > 510) {
return _mappederrno (EINVAL);
RIA.errno = EINVAL;
return __mappederrno(RIA.errno);
}
while (oldpathlen) {
ria_push_char (oldpath[--oldpathlen]);

View File

@@ -5,7 +5,8 @@ int __fastcall__ write_xstack (const void* buf, unsigned count, int fildes)
{
unsigned i;
if (count > 512) {
return _mappederrno (EINVAL);
RIA.errno = EINVAL;
return __mappederrno(RIA.errno);
}
for (i = count; i;) {
ria_push_char (((char*)buf)[--i]);