[nga-c] now truncate input tokens from files where the token is bigger than the TIB. Ensure the token is null terminated if truncated.
FossilOrigin-Name: b8175efce9504446dadb958daf9d8f16a53c95d54fa01f35e3b6566f34919f92
This commit is contained in:
parent
5b5609688c
commit
5a2867cbb9
5 changed files with 947 additions and 935 deletions
|
@ -55,6 +55,8 @@
|
||||||
- now report "<none>" for `script:name` if no file is being
|
- now report "<none>" for `script:name` if no file is being
|
||||||
run
|
run
|
||||||
- now report 0 for `script:arguments` if not running a program
|
- now report 0 for `script:arguments` if not running a program
|
||||||
|
- source read from a file now truncates (w/null termination)
|
||||||
|
input tokens bigger than the defined text input buffer
|
||||||
|
|
||||||
Future Notes
|
Future Notes
|
||||||
|
|
||||||
|
|
|
@ -852,8 +852,12 @@ variables.
|
||||||
:s:next (-)
|
:s:next (-)
|
||||||
&Current v:inc
|
&Current v:inc
|
||||||
@Current @TempStrings eq? [ #0 !Current ] if ;
|
@Current @TempStrings eq? [ #0 !Current ] if ;
|
||||||
|
:truncate (s-s)
|
||||||
|
dup s:length @TempStringMax n:dec gt?
|
||||||
|
[ #0 over @TempStringMax + store ] if ;
|
||||||
---reveal---
|
---reveal---
|
||||||
:s:temp (s-s) dup s:length n:inc s:pointer swap copy
|
:s:temp (s-s) truncate
|
||||||
|
dup s:length n:inc s:pointer swap copy
|
||||||
s:pointer s:next ;
|
s:pointer s:next ;
|
||||||
:s:empty (-s) s:pointer s:next #0 over store ;
|
:s:empty (-s) s:pointer s:next #0 over store ;
|
||||||
}}
|
}}
|
||||||
|
|
BIN
ngaImage
BIN
ngaImage
Binary file not shown.
1870
vm/nga-c/image.c
1870
vm/nga-c/image.c
File diff suppressed because it is too large
Load diff
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#define ACTIVE vm->cpu[vm->active]
|
#define ACTIVE vm->cpu[vm->active]
|
||||||
#define TIB vm->memory[7]
|
#define TIB vm->memory[7]
|
||||||
|
#define TIB_END vm->memory[8]
|
||||||
|
|
||||||
#define MAX_DEVICES 32
|
#define MAX_DEVICES 32
|
||||||
#define MAX_OPEN_FILES 32
|
#define MAX_OPEN_FILES 32
|
||||||
|
@ -707,6 +708,9 @@ V execute(NgaState *vm, CELL cell) {
|
||||||
|
|
||||||
V evaluate(NgaState *vm, char *s) {
|
V evaluate(NgaState *vm, char *s) {
|
||||||
if (strlen(s) == 0) return;
|
if (strlen(s) == 0) return;
|
||||||
|
if (strlen(s) > (TIB_END - TIB)) {
|
||||||
|
s[TIB_END - TIB] = 0;
|
||||||
|
}
|
||||||
string_inject(vm, s, TIB);
|
string_inject(vm, s, TIB);
|
||||||
stack_push(vm, TIB);
|
stack_push(vm, TIB);
|
||||||
execute(vm, vm->interpret);
|
execute(vm, vm->interpret);
|
||||||
|
|
Loading…
Reference in a new issue