textbufferserialize: reject bad section lengths

Negative lengths or lengths running past the data used to hang or read
out of bounds.
This commit is contained in:
Daemonratte 2026-10-15 11:30:51 +02:00
commit 24a2f6dad4

View file

@ -1746,7 +1746,9 @@ read_headers (const gchar *start,
{
section_len = read_int ((const guchar *) start + i + 26);
if (i + 30 + section_len > len)
/* a length below zero would go back, and one past the end
* would overflow the sum */
if (section_len < 0 || section_len > len - i - 30)
goto error;
header = g_new0 (Header, 1);