Skip to content

Commit

Permalink
Fixed fuzzing issue #66279 (asan oss-fuzz in pixa_recog_fuzzer)
Browse files Browse the repository at this point in the history
* test for index before doing lookup in font and baseline tables
  • Loading branch information
DanBloomberg committed Jan 29, 2024
1 parent 0d44776 commit f86cdab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ PIXA *pixa;
return NULL;
if (!bmf)
return (PIX *)ERROR_PTR("bmf not defined", __func__, NULL);
if (index < 32 || index >= 127)
return (PIX *)ERROR_PTR("invalid index", __func__, NULL);

i = bmf->fonttab[index];
if (i == UNDEF) {
Expand Down Expand Up @@ -245,6 +247,8 @@ PIXA *pixa;
return ERROR_INT("bmf not defined", __func__, 1);
if ((index = (l_int32)chr) == 10) /* NL */
return 0;
if (index < 32 || index >= 127)
return ERROR_INT("invalid index", __func__, 1);

i = bmf->fonttab[index];
if (i == UNDEF) {
Expand Down Expand Up @@ -281,6 +285,8 @@ l_int32 bl, index;
return ERROR_INT("bmf not defined", __func__, 1);
if ((index = (l_int32)chr) == 10) /* NL */
return 0;
if (index < 32 || index >= 127)
return ERROR_INT("invalid index", __func__, 1);

bl = bmf->baselinetab[index];
if (bl == UNDEF) {
Expand Down

0 comments on commit f86cdab

Please sign in to comment.