added protection against too long file header

This commit is contained in:
FeralChild64 committed 2019-12-24 22:09:08 +01:00
1 parent 1829ef94e7
commit 171c237c8f
3 files changed
+18 -8

No files matched your search

+1 -1
View File
@@ -89,7 +89,7 @@
.label C3PO = $94 // flag - is BSOUR content valid .label C3PO = $94 // flag - is BSOUR content valid
.label BSOUR = $95 // serial bus buffered output byte .label BSOUR = $95 // serial bus buffered output byte
.label SYNO = $96 // -- NOT IMPLEMENTED -- .label SYNO = $96 // -- NOT IMPLEMENTED --
.label XSAV = $97 // temporary register storage for ASCII related routines [!] usage details might differ .label XSAV = $97 // temporary register storage for ASCII/tape related routines [!] usage details might differ
.label LDTND = $98 // number of entries in LAT / FAT / SAT tables .label LDTND = $98 // number of entries in LAT / FAT / SAT tables
.label DFLTN = $99 // default input device .label DFLTN = $99 // default input device
.label DFLTO = $9A // default output device .label DFLTO = $9A // default output device
+3 -1
View File
@@ -81,7 +81,8 @@ load_tape_normal_header:
// Retrieve the header // Retrieve the header
jsr tape_normal_pilot_header jsr tape_normal_pilot_header
jsr tape_normal_get_data // XXX limit it to 192 bytes ldy #$C1 // size limit (including checksum)
jsr tape_normal_get_data
bcs load_tape_normal_header // unable to read block, try again bcs load_tape_normal_header // unable to read block, try again
// Check header type // Check header type
@@ -121,6 +122,7 @@ load_tape_normal_payload:
// Retrieve data // Retrieve data
jsr tape_normal_pilot_data jsr tape_normal_pilot_data
ldy #$00 // no data size limit
jsr tape_normal_get_data jsr tape_normal_get_data
bcs_far tape_load_error bcs_far tape_load_error
+14 -6
View File
@@ -3,7 +3,7 @@
// Tape (normal) helper routine - data block reading // Tape (normal) helper routine - data block reading
// //
// Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too // Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too
// // .Y not equal to 0 - returns error if data block is longer (length includes checksum)
// XXX improve error handling - do not ignore second copy, handle damaged sync part // XXX improve error handling - do not ignore second copy, handle damaged sync part
@@ -14,16 +14,17 @@
tape_normal_get_data: tape_normal_get_data:
// Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html) // Store block size limit
sty XSAV
// Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html)
lda #$00 lda #$00
sta RIPRTY sta RIPRTY
// Read the pilot and sync of the block // Read the pilot and sync of the block
ldy #$89 ldy #$89
jsr tape_normal_sync jsr tape_normal_sync
bcs tape_normal_get_block_done // XXX make it more erroor resistant bcs tape_normal_get_block_done // XXX make it more error resistant
jsr tape_normal_get_marker jsr tape_normal_get_marker
tape_normal_get_data_loop: tape_normal_get_data_loop:
@@ -35,7 +36,7 @@ tape_normal_get_data_loop:
// Store byte, calculate checksum // Store byte, calculate checksum
lda INBIT lda INBIT
ldy #$00 // XXX probably can be optimized for 65C02 ldy #$00 // XXX probably can be optimized out for 65C02
sta (MEMUSS), y sta (MEMUSS), y
eor RIPRTY eor RIPRTY
sta RIPRTY sta RIPRTY
@@ -47,7 +48,14 @@ tape_normal_get_data_loop:
inw MEMUSS+0 inw MEMUSS+0
#endif #endif
jmp tape_normal_get_data_loop // Check block length limit
lda XSAV
beq tape_normal_get_data_loop // no limit requested
dec XSAV
bne tape_normal_get_data_loop
sec
rts
tape_normal_get_checksum: // XXX handle second copy, with pilot starting from $09 tape_normal_get_checksum: // XXX handle second copy, with pilot starting from $09