fix(data): reject partial and malformed map data

This commit is contained in:
2026-08-14 23:09:55 +09:00
parent 38475318db
commit bfe83d0119
10 changed files with 220 additions and 125 deletions

View File

@@ -3,6 +3,7 @@
void
dictionary_candidates(struct ct *t)
{
static char malformed[] = { 'o', 'k', ' ', (char)0x80 };
char many[512], item[8];
char *p;
Dictreq req;
@@ -53,6 +54,11 @@ dictionary_candidates(struct ct *t)
CT_EQ_INT(t, 0, scmp(&req.pre, &res.key));
checkstr(t, "first capped candidate", "c00", &res.kouho[0]);
checkstr(t, "last capped candidate", "c31", &res.kouho[31]);
key = mkstr("malformed");
hmapset(&lang->dict, &key, malformed, sizeof malformed);
req.key = key;
dictlookup(&req, &res);
CT_EQ_INT(t, 0, res.nkouho);
cleanup:
hmapfree(lang->dict);
lang->dict = saved;