Browse code

(uxnasm) Fixed buffer overflow in tokenizer

Devine Lu Linvega authored on 07/01/2023 19:59:00
Showing 3 changed files
... ...
@@ -115,7 +115,7 @@ echo "Assembling(asma).."
115 115
 if [ $norun = 1 ]; then exit; fi
116 116
 
117 117
 echo "Assembling(piano).."
118
-./bin/uxnasm projects/software/piano.tal bin/piano.rom 2> bin/piano.log
118
+./bin/uxnasm projects/software/piano.tal bin/piano.rom
119 119
 
120 120
 echo "Running.."
121 121
 ./bin/uxnemu bin/piano.rom
... ...
@@ -32,8 +32,8 @@ WITH REGARD TO THIS SOFTWARE.
32 32
 int
33 33
 uxn_eval(Uxn *u, Uint16 pc)
34 34
 {
35
-	Uint16 a, b, c, j, k, bs, instr;
36 35
 	Uint8 kptr, *sp;
36
+	Uint16 a, b, c, j, k, bs, instr;
37 37
 	Stack *src, *dst;
38 38
 	if(!pc || u->dev[0x0f]) return 0;
39 39
 	while((instr = u->ram[pc++])) {
... ...
@@ -416,9 +416,9 @@ assemble(FILE *f)
416 416
 {
417 417
 	char w[0x40];
418 418
 	scpy("on-reset", p.scope, 0x40);
419
-	while(fscanf(f, "%63s", w) == 1)
420
-		if(!parse(w, f))
421
-			return error("Unknown token", w);
419
+	while(fscanf(f, "%62s", w) == 1)
420
+		if(slen(w) > 0x3d || !parse(w, f))
421
+			return error("Invalid token", w);
422 422
 	return resolve();
423 423
 }
424 424