add some bounds checking to openprog()
for some absurd reason (none), there was no bounds check anywhere preceding the memmove of prog into mem. ADD THIS
This commit is contained in:
parent
6c07508a33
commit
a252b33fb5
1 changed files with 2 additions and 0 deletions
2
scemu.c
2
scemu.c
|
@ -43,6 +43,8 @@ openprog(char *f, vlong *progsiz)
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return;
|
return;
|
||||||
d = dirfstat(fd);
|
d = dirfstat(fd);
|
||||||
|
if(d->length > 32768)
|
||||||
|
sysfatal("bad program: bigger than 32K, please shrink it");
|
||||||
*progsiz = d->length;
|
*progsiz = d->length;
|
||||||
free(d);
|
free(d);
|
||||||
prog = malloc(*progsiz);
|
prog = malloc(*progsiz);
|
||||||
|
|
Loading…
Add table
Reference in a new issue