mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
mpegts: Fix descriptor_from_dvb_service
Various leaks/overwrites issues
This commit is contained in:
parent
aaee4dc23b
commit
123f642d5e
2 changed files with 27 additions and 16 deletions
|
@ -467,7 +467,7 @@ GstMpegTsDescriptor *
|
||||||
gst_mpegts_descriptor_from_dvb_service (GstMpegTsDVBServiceType service_type,
|
gst_mpegts_descriptor_from_dvb_service (GstMpegTsDVBServiceType service_type,
|
||||||
const gchar * service_name, const gchar * service_provider)
|
const gchar * service_name, const gchar * service_provider)
|
||||||
{
|
{
|
||||||
GstMpegTsDescriptor *descriptor;
|
GstMpegTsDescriptor *descriptor = NULL;
|
||||||
guint8 *conv_provider_name = NULL, *conv_service_name = NULL;
|
guint8 *conv_provider_name = NULL, *conv_service_name = NULL;
|
||||||
gsize provider_size = 0, service_size = 0;
|
gsize provider_size = 0, service_size = 0;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
@ -478,13 +478,14 @@ gst_mpegts_descriptor_from_dvb_service (GstMpegTsDVBServiceType service_type,
|
||||||
if (!conv_provider_name) {
|
if (!conv_provider_name) {
|
||||||
GST_WARNING ("Could not find proper encoding for string `%s`",
|
GST_WARNING ("Could not find proper encoding for string `%s`",
|
||||||
service_provider);
|
service_provider);
|
||||||
return NULL;
|
goto beach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (provider_size >= 256) {
|
if (provider_size >= 256) {
|
||||||
g_free (conv_provider_name);
|
GST_WARNING ("Service provider string too big (%" G_GSIZE_FORMAT " > 256)",
|
||||||
g_return_val_if_reached (NULL);
|
provider_size);
|
||||||
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service_name) {
|
if (service_name) {
|
||||||
|
@ -493,14 +494,14 @@ gst_mpegts_descriptor_from_dvb_service (GstMpegTsDVBServiceType service_type,
|
||||||
if (!conv_service_name) {
|
if (!conv_service_name) {
|
||||||
GST_WARNING ("Could not find proper encoding for string `%s`",
|
GST_WARNING ("Could not find proper encoding for string `%s`",
|
||||||
service_name);
|
service_name);
|
||||||
return NULL;
|
goto beach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service_size >= 256) {
|
if (service_size >= 256) {
|
||||||
g_free (conv_provider_name);
|
GST_WARNING ("Service name string too big (%" G_GSIZE_FORMAT " > 256)",
|
||||||
g_free (conv_service_name);
|
service_size);
|
||||||
g_return_val_if_reached (NULL);
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptor =
|
descriptor =
|
||||||
|
@ -510,13 +511,19 @@ gst_mpegts_descriptor_from_dvb_service (GstMpegTsDVBServiceType service_type,
|
||||||
data = descriptor->data + 2;
|
data = descriptor->data + 2;
|
||||||
*data++ = service_type;
|
*data++ = service_type;
|
||||||
*data++ = provider_size;
|
*data++ = provider_size;
|
||||||
memcpy (data, conv_provider_name, provider_size);
|
if (conv_provider_name)
|
||||||
|
memcpy (data, conv_provider_name, provider_size);
|
||||||
|
|
||||||
data += provider_size;
|
data += provider_size;
|
||||||
*data++ = service_size;
|
*data++ = service_size;
|
||||||
memcpy (data, conv_service_name, service_size);
|
if (conv_service_name)
|
||||||
|
memcpy (data, conv_service_name, service_size);
|
||||||
|
|
||||||
g_free (conv_provider_name);
|
beach:
|
||||||
g_free (conv_service_name);
|
if (conv_service_name)
|
||||||
|
g_free (conv_service_name);
|
||||||
|
if (conv_provider_name)
|
||||||
|
g_free (conv_provider_name);
|
||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,10 +533,14 @@ GST_START_TEST (test_mpegts_dvb_descriptors)
|
||||||
/* Descriptor should fail if string is more than 255 bytes */
|
/* Descriptor should fail if string is more than 255 bytes */
|
||||||
memset (long_string, 0x41, 256);
|
memset (long_string, 0x41, 256);
|
||||||
long_string[256] = 0x00;
|
long_string[256] = 0x00;
|
||||||
ASSERT_CRITICAL (gst_mpegts_descriptor_from_dvb_service
|
desc =
|
||||||
(GST_DVB_SERVICE_DIGITAL_TELEVISION, long_string, NULL));
|
gst_mpegts_descriptor_from_dvb_service
|
||||||
ASSERT_CRITICAL (gst_mpegts_descriptor_from_dvb_service
|
(GST_DVB_SERVICE_DIGITAL_TELEVISION, long_string, NULL);
|
||||||
(GST_DVB_SERVICE_DIGITAL_TELEVISION, NULL, long_string));
|
fail_if (desc != NULL);
|
||||||
|
desc =
|
||||||
|
gst_mpegts_descriptor_from_dvb_service
|
||||||
|
(GST_DVB_SERVICE_DIGITAL_TELEVISION, NULL, long_string);
|
||||||
|
fail_if (desc != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
Loading…
Reference in a new issue