@ -287,6 +287,8 @@ cpm_word fcb_read(cpm_byte *fcb, cpm_byte *dma)
redir_Msg ( " (from %lx) \n " , zxlseek ( handle , 0 , SEEK_CUR ) ) ;
redir_Msg ( " (from %lx) \n " , zxlseek ( handle , 0 , SEEK_CUR ) ) ;
/* Read in the required amount */
/* Read in the required amount */
memset ( dma , 0x00 , redir_rec_len ) ;
# ifdef WIN32
# ifdef WIN32
{
{
@ -300,6 +302,12 @@ cpm_word fcb_read(cpm_byte *fcb, cpm_byte *dma)
rv = read ( handle , dma , redir_rec_len ) ;
rv = read ( handle , dma , redir_rec_len ) ;
# endif
# endif
if ( rv = = - 1 )
memset ( dma , 0x00 , redir_rec_len ) ;
if ( ( rv > = 0 ) & & ( rv < redir_rec_len ) )
memset ( dma + rv , 0x00 , redir_rec_len - rv ) ;
/* rd_len = length supposedly read, bytes. Round to nearest 128 bytes.
/* rd_len = length supposedly read, bytes. Round to nearest 128 bytes.
*/
*/
rd_len = ( ( rv + 127 ) / 128 ) * 128 ;
rd_len = ( ( rv + 127 ) / 128 ) * 128 ;
@ -493,6 +501,9 @@ cpm_word fcb_randrd(cpm_byte *fcb, cpm_byte *dma)
if ( ( handle = redir_verify_fcb ( fcb ) ) < 0 ) return 9 ; /* Invalid FCB */
if ( ( handle = redir_verify_fcb ( fcb ) ) < 0 ) return 9 ; /* Invalid FCB */
if ( zxlseek ( handle , offs , SEEK_SET ) < 0 ) return 6 ; /* bad record no. */
if ( zxlseek ( handle , offs , SEEK_SET ) < 0 ) return 6 ; /* bad record no. */
memset ( dma , 0x00 , redir_rec_len ) ;
# ifdef WIN32
# ifdef WIN32
{
{
BOOL b ;
BOOL b ;
@ -504,6 +515,13 @@ cpm_word fcb_randrd(cpm_byte *fcb, cpm_byte *dma)
# else
# else
rv = read ( handle , dma , redir_rec_len ) ;
rv = read ( handle , dma , redir_rec_len ) ;
# endif
# endif
if ( rv = = - 1 )
memset ( dma , 0x00 , redir_rec_len ) ;
if ( ( rv > = 0 ) & & ( rv < redir_rec_len ) )
memset ( dma + rv , 0x00 , redir_rec_len - rv ) ;
zxlseek ( handle , offs , SEEK_SET ) ;
zxlseek ( handle , offs , SEEK_SET ) ;
redir_put_fcb_pos ( fcb , offs ) ;
redir_put_fcb_pos ( fcb , offs ) ;
@ -579,6 +597,8 @@ cpm_word fcb_randwz(cpm_byte *fcb, cpm_byte *dma)
while ( len < offs )
while ( len < offs )
{
{
memset ( zerorec , 0 , sizeof ( zerorec ) ) ;
rl = sizeof ( zerorec ) ;
rl = sizeof ( zerorec ) ;
if ( ( offs - len ) < sizeof ( zerorec ) ) rl = offs - len ;
if ( ( offs - len ) < sizeof ( zerorec ) ) rl = offs - len ;
# ifdef WIN32
# ifdef WIN32