mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
ebml-read: Zero-sized ints/uints/floats have a value of 0 according to the EBML spec
This commit is contained in:
parent
e4a5f0911e
commit
f44e5e630b
1 changed files with 18 additions and 4 deletions
|
@ -394,13 +394,19 @@ gst_ebml_read_uint (GstEbmlRead * ebml, guint32 * id, guint64 * num)
|
|||
if (ret != GST_FLOW_OK)
|
||||
return ret;
|
||||
|
||||
if (size < 1 || size > 8) {
|
||||
if (size > 8) {
|
||||
GST_ERROR_OBJECT (ebml->el,
|
||||
"Invalid integer element size %d at position %" G_GUINT64_FORMAT " (0x%"
|
||||
G_GINT64_MODIFIER "x)", size, gst_ebml_read_get_pos (ebml) - size,
|
||||
gst_ebml_read_get_pos (ebml) - size);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
*num = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
*num = 0;
|
||||
while (size > 0) {
|
||||
*num = (*num << 8) | *data;
|
||||
|
@ -427,7 +433,7 @@ gst_ebml_read_sint (GstEbmlRead * ebml, guint32 * id, gint64 * num)
|
|||
if (ret != GST_FLOW_OK)
|
||||
return ret;
|
||||
|
||||
if (size < 1 || size > 8) {
|
||||
if (size > 8) {
|
||||
GST_ERROR_OBJECT (ebml->el,
|
||||
"Invalid integer element size %d at position %" G_GUINT64_FORMAT " (0x%"
|
||||
G_GINT64_MODIFIER "x)", size, gst_ebml_read_get_pos (ebml) - size,
|
||||
|
@ -435,6 +441,11 @@ gst_ebml_read_sint (GstEbmlRead * ebml, guint32 * id, gint64 * num)
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
*num = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
*num = 0;
|
||||
if (*data & 0x80) {
|
||||
negative = 1;
|
||||
|
@ -505,7 +516,7 @@ gst_ebml_read_float (GstEbmlRead * ebml, guint32 * id, gdouble * num)
|
|||
if (ret != GST_FLOW_OK)
|
||||
return ret;
|
||||
|
||||
if (size != 4 && size != 8 && size != 10) {
|
||||
if (size != 0 && size != 4 && size != 8 && size != 10) {
|
||||
GST_ERROR_OBJECT (ebml->el,
|
||||
"Invalid float element size %d at position %" G_GUINT64_FORMAT " (0x%"
|
||||
G_GINT64_MODIFIER "x)", size, gst_ebml_read_get_pos (ebml) - size,
|
||||
|
@ -527,8 +538,11 @@ gst_ebml_read_float (GstEbmlRead * ebml, guint32 * id, gdouble * num)
|
|||
d = GDOUBLE_FROM_BE (d);
|
||||
|
||||
*num = d;
|
||||
} else {
|
||||
} else if (size == 10) {
|
||||
*num = _ext2dbl (data);
|
||||
} else {
|
||||
/* size == 0 means a value of 0.0 */
|
||||
*num = 0.0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue