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

+3 -1
View File
@@ -81,7 +81,8 @@ load_tape_normal_header:
// Retrieve the 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
// Check header type
@@ -121,6 +122,7 @@ load_tape_normal_payload:
// Retrieve data
jsr tape_normal_pilot_data
ldy #$00 // no data size limit
jsr tape_normal_get_data
bcs_far tape_load_error
+14 -6
View File
@@ -3,7 +3,7 @@
// Tape (normal) helper routine - data block reading
//
// 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
@@ -14,16 +14,17 @@
tape_normal_get_data:
// Store block size limit
sty XSAV
// Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html)
lda #$00
sta RIPRTY
// Read the pilot and sync of the block
ldy #$89
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
tape_normal_get_data_loop:
@@ -35,7 +36,7 @@ tape_normal_get_data_loop:
// Store byte, calculate checksum
lda INBIT
ldy #$00 // XXX probably can be optimized for 65C02
ldy #$00 // XXX probably can be optimized out for 65C02
sta (MEMUSS), y
eor RIPRTY
sta RIPRTY
@@ -47,7 +48,14 @@ tape_normal_get_data_loop:
inw MEMUSS+0
#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