mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
wavparse: Fix parsing of acid chunk
Simply casting the bytes to a struct can lead to crashes because of unaligned reads, and is also missing the endianness swapping that is necessary on big endian architectures. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8042>
This commit is contained in:
parent
4c198f4891
commit
296e17b4ea
1 changed files with 5 additions and 7 deletions
|
@ -1434,8 +1434,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_RIFF_TAG_acid:{
|
case GST_RIFF_TAG_acid:{
|
||||||
const gst_riff_acid *acid = NULL;
|
const guint data_size = 24;
|
||||||
const guint data_size = sizeof (gst_riff_acid);
|
|
||||||
gfloat tempo;
|
gfloat tempo;
|
||||||
|
|
||||||
GST_INFO_OBJECT (wav, "Have acid chunk");
|
GST_INFO_OBJECT (wav, "Have acid chunk");
|
||||||
|
@ -1449,13 +1448,13 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (wav->streaming) {
|
if (wav->streaming) {
|
||||||
|
const guint8 *data;
|
||||||
if (!gst_wavparse_peek_chunk (wav, &tag, &size)) {
|
if (!gst_wavparse_peek_chunk (wav, &tag, &size)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
gst_adapter_flush (wav->adapter, 8);
|
gst_adapter_flush (wav->adapter, 8);
|
||||||
acid = (const gst_riff_acid *) gst_adapter_map (wav->adapter,
|
data = gst_adapter_map (wav->adapter, data_size);
|
||||||
data_size);
|
tempo = GST_READ_FLOAT_LE (data + 20);
|
||||||
tempo = acid->tempo;
|
|
||||||
gst_adapter_unmap (wav->adapter);
|
gst_adapter_unmap (wav->adapter);
|
||||||
} else {
|
} else {
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
|
@ -1466,8 +1465,7 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
||||||
&buf)) != GST_FLOW_OK)
|
&buf)) != GST_FLOW_OK)
|
||||||
goto header_pull_error;
|
goto header_pull_error;
|
||||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
acid = (const gst_riff_acid *) map.data;
|
tempo = GST_READ_FLOAT_LE (map.data + 20);
|
||||||
tempo = acid->tempo;
|
|
||||||
gst_buffer_unmap (buf, &map);
|
gst_buffer_unmap (buf, &map);
|
||||||
}
|
}
|
||||||
/* send data as tags */
|
/* send data as tags */
|
||||||
|
|
Loading…
Reference in a new issue