[base] Avoid negative bitmap stroke dimensions (#48985).

* src/base/ftobjs.c (FT_Open_Face): Check whether negation was
actually successful.  For example, this can fail for value
-32768 if the type is `signed short'.  If there are problems,
disable the stroke.
This commit is contained in:
Werner Lemberg 2016-09-03 08:20:31 +02:00
parent f0fa7a67bf
commit b98dfda392
2 changed files with 24 additions and 2 deletions

View File

@ -1,3 +1,12 @@
2016-09-03 Werner Lemberg <wl@gnu.org>
[base] Avoid negative bitmap stroke dimensions (#48985).
* src/base/ftobjs.c (FT_Open_Face): Check whether negation was
actually successful. For example, this can fail for value
-32768 if the type is `signed short'. If there are problems,
disable the stroke.
2016-09-03 Werner Lemberg <wl@gnu.org>
[cff] Avoid null pointer passed to FT_MEM_COPY (#48984).

View File

@ -2314,11 +2314,24 @@
if ( bsize->height < 0 )
bsize->height = (FT_Short)-bsize->height;
bsize->height = -bsize->height;
if ( bsize->x_ppem < 0 )
bsize->x_ppem = (FT_Short)-bsize->x_ppem;
bsize->x_ppem = -bsize->x_ppem;
if ( bsize->y_ppem < 0 )
bsize->y_ppem = -bsize->y_ppem;
/* check whether negation actually has worked */
if ( bsize->height < 0 || bsize->x_ppem < 0 || bsize->y_ppem < 0 )
{
FT_TRACE0(( "FT_Open_Face:"
" Invalid bitmap dimensions for stroke %d,"
" now disabled\n", i ));
bsize->width = 0;
bsize->height = 0;
bsize->size = 0;
bsize->x_ppem = 0;
bsize->y_ppem = 0;
}
}
}