fix: harden small core containers

This commit is contained in:
2026-08-12 15:54:16 +09:00
parent cec62cc40f
commit 103f2ec448
11 changed files with 136 additions and 18 deletions

View File

@@ -724,6 +724,12 @@ keystroke(u32int ks, u32int mod, Str *com)
}
if(im.l->trans == nil)
return 0;
if(im.pre.n >= Maxrunes ||
(isjp(&im) && im.pre.n + im.raw.n >= Maxrunes)){
commit(com);
reset();
return 0;
}
if(im.l->lang == LangKO)
ks = kokey(ks, mod);
n = dotrans(ks, com);
@@ -858,7 +864,9 @@ mapinit(char *dir)
for(i = 0; i < nelem(langs); i++){
if(langs[i].mapname == nil)
continue;
snprint(path, sizeof(path), "%s/%s.map", dir, langs[i].mapname);
if(snprint(path, sizeof(path), "%s/%s.map", dir,
langs[i].mapname) >= (int)sizeof path)
die("map path too long: %s/%s.map", dir, langs[i].mapname);
langs[i].map = trieopen(path);
}
}