[tfman] fix two problems found by fuzzing #2475

This commit is contained in:
nick black 2021-12-15 04:27:13 -05:00 committed by nick black
parent acffa61557
commit 5ea69031ca
2 changed files with 8 additions and 6 deletions

View File

@ -351,12 +351,14 @@ draw_domnode(struct ncplane* p, const pagedom* dom, const pagenode* n,
putpara(p, n->text); putpara(p, n->text);
} }
}else{ }else{
if(n->text){
ncplane_set_styles(p, NCSTYLE_BOLD | NCSTYLE_ITALIC); ncplane_set_styles(p, NCSTYLE_BOLD | NCSTYLE_ITALIC);
ncplane_set_fg_rgb(p, 0xff6a00); ncplane_set_fg_rgb(p, 0xff6a00);
ncplane_putstr_aligned(p, -1, NCALIGN_CENTER, n->text); ncplane_putstr_aligned(p, -1, NCALIGN_CENTER, n->text);
ncplane_set_fg_default(p); ncplane_set_fg_default(p);
ncplane_set_styles(p, NCSTYLE_NONE); ncplane_set_styles(p, NCSTYLE_NONE);
} }
}
*wrotetext = true; *wrotetext = true;
break; break;
default: default:

View File

@ -104,7 +104,7 @@ const trofftype* get_type(const struct troffnode* trie, const unsigned char** ws
++*ws; ++*ws;
--len; --len;
while(len && !isspace(**ws) && **ws){ while(len && !isspace(**ws) && **ws){
if(**ws > sizeof(trie->next) / sizeof(*trie->next)){ // illegal command if(**ws >= sizeof(trie->next) / sizeof(*trie->next)){ // illegal command
return NULL; return NULL;
} }
if((trie = trie->next[**ws]) == NULL){ if((trie = trie->next[**ws]) == NULL){