mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Add checks to the read_io, seek_io and close_io routines to ensure that they do not perform any actions if an invalid
file handle (-1) is passed. This resolves the issue with extra arguments being left on the Forth stack when an invalid device access is attempted. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@764 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Mark Cave-Ayland
parent
d183b53338
commit
d2f9a689ac
@@ -164,27 +164,40 @@ get_fstype( int fd )
|
|||||||
int
|
int
|
||||||
read_io( int fd, void *buf, size_t cnt )
|
read_io( int fd, void *buf, size_t cnt )
|
||||||
{
|
{
|
||||||
priv_fd_t *fdp = file_descriptors[fd];
|
priv_fd_t *fdp;
|
||||||
ucell ret;
|
ucell ret;
|
||||||
|
|
||||||
PUSH( (ucell)buf );
|
if (fd != -1) {
|
||||||
PUSH( cnt );
|
fdp = file_descriptors[fd];
|
||||||
call_package( fdp->read_xt, fdp->ih );
|
|
||||||
ret = POP();
|
|
||||||
|
|
||||||
if( !ret && cnt )
|
PUSH( (ucell)buf );
|
||||||
|
PUSH( cnt );
|
||||||
|
call_package( fdp->read_xt, fdp->ih );
|
||||||
|
ret = POP();
|
||||||
|
|
||||||
|
if( !ret && cnt )
|
||||||
|
ret = -1;
|
||||||
|
} else {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
seek_io( int fd, llong offs )
|
seek_io( int fd, llong offs )
|
||||||
{
|
{
|
||||||
priv_fd_t *fdp = file_descriptors[fd];
|
priv_fd_t *fdp;
|
||||||
|
|
||||||
DPUSH( offs );
|
if (fd != -1) {
|
||||||
call_package( fdp->seek_xt, fdp->ih );
|
fdp = file_descriptors[fd];
|
||||||
return ((((cell)POP()) >= 0)? 0 : -1);
|
|
||||||
|
DPUSH( offs );
|
||||||
|
call_package( fdp->seek_xt, fdp->ih );
|
||||||
|
return ((((cell)POP()) >= 0)? 0 : -1);
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
llong
|
llong
|
||||||
@@ -203,13 +216,17 @@ tell( int fd )
|
|||||||
int
|
int
|
||||||
close_io( int fd )
|
close_io( int fd )
|
||||||
{
|
{
|
||||||
priv_fd_t *fdp = file_descriptors[fd];
|
priv_fd_t *fdp;
|
||||||
|
|
||||||
if( fdp->do_close )
|
if (fd != -1) {
|
||||||
close_dev( fdp->ih );
|
fdp = file_descriptors[fd];
|
||||||
free( fdp );
|
|
||||||
|
|
||||||
file_descriptors[fd]=NULL;
|
if( fdp->do_close )
|
||||||
|
close_dev( fdp->ih );
|
||||||
|
free( fdp );
|
||||||
|
|
||||||
|
file_descriptors[fd]=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user