textbufferserialize: reject sections whose length is negative or runs past the data, instead of hanging or reading beyond it

This commit is contained in:
Daemonratte 2026-10-16 13:44:26 +02:00
commit d0f4c65e17
No known key found for this signature in database

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);