A few important fixes in TAPClean

I just finished putting in a few fixes in TAPClean, now at version 0.33-pre13.

Zoë reported an issue with a “Bleepload” title she had dumped and I was able to appreciate that the issue was only presenting itself on non-Windows systems, due to a different memory management there.
The root cause of the issue was a lack of memory boundary checks in the trailer pulse read loop. As I was at it, I looked for similar issues and found that there were, in fact, similar scenarios in which memory boundary checks were either absent or wrong, which led me to fixing them in: “Bleepload”, “Bleepload Special”, “Novaload F1”, “Novaload F2”, “Ocean”, “Rasterload”, “Snakeload 5.0 T1”, “Snakeload 5.0 T2”, “Snakeload 5.1”.

Subchrist, the author of “Final TAP”, had himself appreciated the possible consequences of unchecked memory boundaries and even noted them in the module for “Rasterload”:

/* this should take care of it... */
if(eof<tap.len) /* safety precaution, this was causing a crash.. */ {
  while(tap.tmem[eof+1]>ft[RASTER].lp-tol && tap.tmem[eof+1]<ft[RASTER].lp+tol)
    eof++;
}

Unfortunately even the above precaution is not quite comprehensive as it should be something like (validate the memory read address before each read):

while(eof<tap.len-1 && tap.tmem[eof+1]>ft[RASTER].lp-tol && tap.tmem[eof+1]<ft[RASTER].lp+tol)
  eof++;

Alas, the above mentioned modules have not yet been rewritten for consistency with new and more robust code, but that’s something on my TODO list for this year 🙂

BTW, the above checks in newly written (and re-written) modules read as per below:

/* Trace 'eof' to end of trailer (any value, both bit 1 and bit 0 pulses) */
h = 0;
while (eof < tap.len - 1 &&
    h++ < MAXTRAILER &&
    readttbit(eof + 1, lp, sp, tp) >= 0)
  eof++;

Actually, a boundary check on pos = eof + 1 is already performed within readttbit(), which also deals with the “-skewadapt” option, but I had decided to keep one check in the trailer read-in loop for clarity as it’s a lightweight operation compared to the search itself.

I will provide binaries in a few days possibly through an official 0.33 release on Sourceforge.

Stay tuned!

This entry was posted in Retrocomputing, Technical and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s