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:
Yuvia 2025-09-07 21:06:35 +00:00
parent 6c07508a33
commit a252b33fb5

View file

@ -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);