wavparse: guard against overflow when comparing chunk sizes

Could be rewritten as lsize > (size - 8) a well, but the
extra check seems clearer. Doesn't look like it was problematic,
lsize wasn't actually used when parsing the sub-chunks.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/994>
This commit is contained in:
Tim-Philipp Müller 2021-05-23 13:24:21 +01:00
parent 4f2189a6e1
commit 3dd8de1d7c

View file

@ -930,7 +930,7 @@ gst_wavparse_adtl_chunk (GstWavParse * wav, const guint8 * data, guint32 size)
ltag = GST_READ_UINT32_LE (data + offset); ltag = GST_READ_UINT32_LE (data + offset);
lsize = GST_READ_UINT32_LE (data + offset + 4); lsize = GST_READ_UINT32_LE (data + offset + 4);
if (lsize + 8 > size) { if (lsize > (G_MAXUINT - 8) || lsize + 8 > size) {
GST_WARNING_OBJECT (wav, "Invalid adtl size: %u + 8 > %u", lsize, size); GST_WARNING_OBJECT (wav, "Invalid adtl size: %u + 8 > %u", lsize, size);
return FALSE; return FALSE;
} }