From cd18873bdf82b327dfc5f6a15da40ca9f31204c3 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 9 Mar 2025 03:33:31 -0400 Subject: listamsb: fix invalid token detection in expand_token() (for the -D option). --- listamsb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'listamsb.c') diff --git a/listamsb.c b/listamsb.c index 9eff533..2581a61 100644 --- a/listamsb.c +++ b/listamsb.c @@ -569,10 +569,15 @@ void expand_token(int ext, unsigned char t, unsigned char *buf) { return; } - if(ext) + if(ext) { + if(t > MAX_EXT_TOK) + die("invalid token in program, can't decrunch"); result = ext_tokens[t - MIN_EXT_TOK]; - else + } else { + if(t > MAX_STD_TOK) + die("invalid token in program, can't decrunch"); result = std_tokens[t - MIN_STD_TOK]; + } strcpy((char *)buf, result); } @@ -589,9 +594,6 @@ int need_space_between(int ext1, int ext2, unsigned char t1, unsigned char t2) { if(!t2) return 0; /* end of line */ if(t1 < 0x80 && t2 < 0x80) return 0; /* 2 ASCII chars */ - if(t1 > MAX_STD_TOK || t2 > MAX_STD_TOK) - die("invalid token in program, can't decrunch"); - expand_token(ext1, t1, tok1); expand_token(ext2, t2, tok2); t1last = tok1[strlen((char *)tok1) - 1]; /* "PRINT" => "T" */ -- cgit v1.2.3