Subject: bug#35814: 27.0.50; Broken font display

From: Andy Moreton <[email-masked]>
Date: Tue, 21 May 2019 20:14:17 +0100

On Tue 21 May 2019, Alex Gramiak wrote:

> Juri Linkov <[email-masked]> writes:
>
>> Some yesterday's commit in master broke the display of the text that uses
>> the font "-misc-fixed-medium-r-normal--10-*-*-*-c-60-iso10646-*"
>> in GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
>> Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
>> System Description: Linux Mint 19
>>
>> Screenshot:
>
> It's probably due to my a4fe9c70af7 commit, sorry.
>
> I tested with all X font backends -- what's the value of
> (frame-parameter nil 'font-backend) normally?
>
> And is it only that font, or other fonts as well?

Alex, at the end of xfont_draw() in xfont.c, we now have:

      else
        {
          const unsigned code = s->char2b[from];
          const XChar2b char2b = { .byte1 = code >> 8,
                                   .byte2 = code & 0xFF };
          XDrawImageString16 (display, FRAME_X_DRAWABLE (s->f),
                              gc, x, y, &char2b, len);
        }

and:
      else
        {
          const unsigned code = s->char2b[from];
          const XChar2b char2b = { .byte1 = code >> 8,
                                   .byte2 = code & 0xFF };
          XDrawString16 (display, FRAME_X_DRAWABLE (s->f),
                         gc, x, y, &char2b, len);
        }

Both of these pass "len", but use a single XChar2b on the stack, so
this causes an overrun (and draws random stack contents).

    AndyM