gmarkup: Fix unvalidated UTF-8 read in markup parsing error pathscec71705406f0b2790422f0c1aa0ff3b4b464b1b204/head
commitcec71705406f0b2790422f0c1aa0ff3b4b464b1b
authorPhilip Withnall <withnall@endlessm.com>
Mon, 30 Jul 2018 17:10:25 +0000 (30 18:10 +0100)
committerPhilip Withnall <withnall@endlessm.com>
Mon, 30 Jul 2018 17:10:25 +0000 (30 18:10 +0100)
treea8162df6cfa4f59c9801736a7bc48264f673ce10
parent2d7423b98600fea11f7fefae3b641d34ea5cc02a
gmarkup: Fix unvalidated UTF-8 read in markup parsing error paths

When formatting the error messages for markup parsing errors, the parser
was unconditionally reading a UTF-8 character from the input buffer —
but the buffer might end with a partial code sequence, resulting in
reading off the end of the buffer by up to three bytes.

Fix this and add a test case, courtesy of pdknsk.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://gitlab.gnome.org/GNOME/glib/issues/1462
glib/gmarkup.c
glib/tests/Makefile.am
glib/tests/markups/fail-50.expected [new file with mode: 0644]
glib/tests/markups/fail-50.gmarkup [new file with mode: 0644]