aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-25 01:59:22 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-25 01:59:22 -0400
commit51b3bdd30fae6305c3475a7d49d507991e63a967 (patch)
treec5c76c871d4f4bb624f30bc41d8593443f6a2589
parentda0f28eec887d690c3c2a69959687284f8eb9982 (diff)
downloadbw-atari8-tools-51b3bdd30fae6305c3475a7d49d507991e63a967.tar.gz
unprotbas: don't corrupt memory if >256 vvtable entries.
-rw-r--r--unprotbas.110
-rw-r--r--unprotbas.c5
-rw-r--r--unprotbas.rst10
3 files changed, 17 insertions, 8 deletions
diff --git a/unprotbas.1 b/unprotbas.1
index 42b551e..2727592 100644
--- a/unprotbas.1
+++ b/unprotbas.1
@@ -294,10 +294,12 @@ variable value table can hold more than 256 values, though the
variable numbers wrap around once they pass 255. The attempt to add
variables past the 128th causes BASIC to respond with \fIERROR\- 4\fP, but
the variable does get added to the tables. \fBunprotbas\fP will preserve
-these extra (useless) entries in the tables, though it will complain
-"Warning: variable #XXX value is corrupt" for value table entries
-256 and up. This is a pathological case, and shouldn\(aqt happen with
-programs that aren\(aqt deliberately written to test this behaviour.
+these extra (useless) entries in the tables.
+.sp
+If there more than 256 entries in the value table, you will see
+"Warning: skipping variable numbers >=256 in value table". This is
+a pathological case, and shouldn\(aqt happen with programs that aren\(aqt
+deliberately crafted to test this behaviour.
.SH COPYRIGHT
.sp
WTFPL. See \fI\%http://www.wtfpl.net/txt/copying/\fP for details.
diff --git a/unprotbas.c b/unprotbas.c
index acbbecf..28af9a5 100644
--- a/unprotbas.c
+++ b/unprotbas.c
@@ -354,6 +354,11 @@ int rebuild_vntable(int write) {
unsigned char type = data[vv] >> 6;
/* fprintf(stderr, "%04x: %04x, %d\n", vv, data[vv], type); */
+ if(varnum == 256) {
+ fprintf(stderr, "Warning: skipping variable numbers >=256 in value table.\n");
+ break;
+ }
+
if(varnum != data[vv+1]) {
fprintf(stderr, "Warning: variable #%d value is corrupt!\n", varnum);
}
diff --git a/unprotbas.rst b/unprotbas.rst
index eca793c..39a051b 100644
--- a/unprotbas.rst
+++ b/unprotbas.rst
@@ -262,9 +262,11 @@ variable value table can hold more than 256 values, though the
variable numbers wrap around once they pass 255. The attempt to add
variables past the 128th causes BASIC to respond with *ERROR- 4*, but
the variable does get added to the tables. **unprotbas** will preserve
-these extra (useless) entries in the tables, though it will complain
-"Warning: variable #XXX value is corrupt" for value table entries
-256 and up. This is a pathological case, and shouldn't happen with
-programs that aren't deliberately written to test this behaviour.
+these extra (useless) entries in the tables.
+
+If there more than 256 entries in the value table, you will see
+"Warning: skipping variable numbers >=256 in value table". This is
+a pathological case, and shouldn't happen with programs that aren't
+deliberately crafted to test this behaviour.
.. include:: manftr.rst