From a1bc00ce5f4a78672717ad8193d5d2426a34d778 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 7 Jan 2023 11:59:00 -0800 Subject: [PATCH] (uxnasm) Fixed buffer overflow in tokenizer --- build.sh | 2 +- src/uxn.c | 2 +- src/uxnasm.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 27b920e..b3a09a8 100755 --- a/build.sh +++ b/build.sh @@ -115,7 +115,7 @@ echo "Assembling(asma).." if [ $norun = 1 ]; then exit; fi echo "Assembling(piano).." -./bin/uxnasm projects/software/piano.tal bin/piano.rom 2> bin/piano.log +./bin/uxnasm projects/software/piano.tal bin/piano.rom echo "Running.." ./bin/uxnemu bin/piano.rom diff --git a/src/uxn.c b/src/uxn.c index b1de3e4..f64461c 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -32,8 +32,8 @@ WITH REGARD TO THIS SOFTWARE. int uxn_eval(Uxn *u, Uint16 pc) { - Uint16 a, b, c, j, k, bs, instr; Uint8 kptr, *sp; + Uint16 a, b, c, j, k, bs, instr; Stack *src, *dst; if(!pc || u->dev[0x0f]) return 0; while((instr = u->ram[pc++])) { diff --git a/src/uxnasm.c b/src/uxnasm.c index 6168c3c..7c9e7b5 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -416,9 +416,9 @@ assemble(FILE *f) { char w[0x40]; scpy("on-reset", p.scope, 0x40); - while(fscanf(f, "%63s", w) == 1) - if(!parse(w, f)) - return error("Unknown token", w); + while(fscanf(f, "%62s", w) == 1) + if(slen(w) > 0x3d || !parse(w, f)) + return error("Invalid token", w); return resolve(); }