aligrudi / neatroff_make

Neatroff top-level makefile
51 stars 15 forks source link

pdf/post crash with long glyph names #8

Closed vuori closed 3 years ago

vuori commented 3 years ago

FontAwesome version 5 contains glyph names which are longer than GNLEN (32). This causes a strcpy buffer overflow in font_glyphput.

Fix for the immediate problem is to increase GNLEN, but perhaps checking the length and skipping the offending glyph with a warning would be nice here?

aligrudi commented 3 years ago

vuori notifications@github.com wrote:

FontAwesome version 5 contains glyph names which are longer than GNLEN (32). This causes a strcpy buffer overflow in font_glyphput.

Fix for the immediate problem is to increase GNLEN, but perhaps checking the length and skipping the offending glyph with a warning would be nice here?

Now Neatpost truncates glyph names at GNLEN, like Neatroff. Also, Neatmkfn warns if glyph names are truncated.

AFAIK, glyph names in OTF are limited to 64 bytes. Maybe we should increase GNLEN?

Ali
vuori commented 3 years ago

Upping to 64 sounds good, that's what I set it to off the cuff. The offending FontAwesome glyph was called american-sign-language-interpreting (35 bytes).

aligrudi commented 3 years ago

vuori notifications@github.com wrote:

Upping to 64 sounds good, that's what I set it to off the cuff. The offending FontAwesome glyph was called american-sign-language-interpreting (35 bytes).

Increasing GNLEN would probably increase Neatroff's memory usage noticeably. If such glyphs appear rarely, maybe we can safely let GNLEN remain 32. We can also remove ILNLEN. Please test the following patch.

Thanks, Ali

diff --git a/dev.c b/dev.c index 10a6783..469fb79 100644 --- a/dev.c +++ b/dev.c @@ -77,7 +77,7 @@ int dev_mnt(int pos, char id, char name) int dev_open(char dir, char dev) { char path[PATHLEN];

vuori commented 3 years ago

After applying the patch to neatroff and reverting the increase to GNLEN in neatpost, I'm still seeing the crash with a long glyph name:

#6  0x000055555555c3bd in strcpy (__src=0x7fffffffd520 "american-sign-language-interpreting", __dest=<optimized out>)
    at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:90
#7  font_glyphput (type=3, name=0x7fffffffd130 "", id=0x7fffffffd520 "american-sign-language-interpreting", fn=0x5555558d9400)
    at font.c:44
aligrudi commented 3 years ago

vuori notifications@github.com wrote:

After applying the patch to neatroff and reverting the increase to GNLEN in neatpost, I'm still seeing the crash with a long glyph name:

#6  0x000055555555c3bd in strcpy (  src=0x7fffffffd520 "american-sign-language-interpreting",   dest=<optimized out>)
    at /usr/include/x86 64-linux-gnu/bits/string fortified.h:90
#7  font glyphput (type=3, name=0x7fffffffd130 "", id=0x7fffffffd520 "american-sign-language-interpreting", fn=0x5555558d9400)
    at font.c:44

I have updated both Neatroff and Neatpost (no need for the patch anymore). Please test it once more. Do you get the same result?

Thanks, Ali

vuori commented 3 years ago

Working with the latest changes, thanks.