rtsptransport: ignore unparsable ranges

Ignore unparsable port ranges instead of erroring out.

Fixes #613591
This commit is contained in:
Wim Taymans 2010-03-24 12:10:38 +01:00
parent 0872ea67f9
commit 4ff230e71b

View file

@ -271,7 +271,7 @@ parse_mode (GstRTSPTransport * transport, const gchar * str)
transport->mode_record = (strstr (str, "record") != NULL); transport->mode_record = (strstr (str, "record") != NULL);
} }
static void static gboolean
parse_range (const gchar * str, GstRTSPRange * range) parse_range (const gchar * str, GstRTSPRange * range)
{ {
gchar *minus; gchar *minus;
@ -303,13 +303,13 @@ parse_range (const gchar * str, GstRTSPRange * range)
range->max = -1; range->max = -1;
} }
return; return TRUE;
invalid_range: invalid_range:
{ {
range->min = -1; range->min = -1;
range->max = -1; range->max = -1;
return; return FALSE;
} }
} }
@ -364,6 +364,12 @@ rtsp_transport_ltrans_as_text (const GstRTSPTransport * transport)
return NULL; return NULL;
} }
#define IS_VALID_PORT_RANGE(range) \
(range.min >= 0 && range.min < 65536 && range.max < 65536)
#define IS_VALID_INTERLEAVE_RANGE(range) \
(range.min >= 0 && range.min < 256 && range.max < 256)
/** /**
* gst_rtsp_transport_parse: * gst_rtsp_transport_parse:
* @str: a transport string * @str: a transport string
@ -470,9 +476,7 @@ gst_rtsp_transport_parse (const gchar * str, GstRTSPTransport * transport)
} else if (g_str_has_prefix (split[i], "interleaved=")) { } else if (g_str_has_prefix (split[i], "interleaved=")) {
RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_INTERLEAVED); RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_INTERLEAVED);
parse_range (split[i] + 12, &transport->interleaved); parse_range (split[i] + 12, &transport->interleaved);
if (transport->interleaved.min < 0 || if (!IS_VALID_INTERLEAVE_RANGE (transport->interleaved))
transport->interleaved.min >= 256 ||
transport->interleaved.max >= 256)
goto invalid_transport; goto invalid_transport;
} else if (g_str_has_prefix (split[i], "ttl=")) { } else if (g_str_has_prefix (split[i], "ttl=")) {
RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_TTL); RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_TTL);
@ -481,24 +485,22 @@ gst_rtsp_transport_parse (const gchar * str, GstRTSPTransport * transport)
goto invalid_transport; goto invalid_transport;
} else if (g_str_has_prefix (split[i], "port=")) { } else if (g_str_has_prefix (split[i], "port=")) {
RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_PORT); RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_PORT);
parse_range (split[i] + 5, &transport->port); if (parse_range (split[i] + 5, &transport->port)) {
if (transport->port.min < 0 || if (!IS_VALID_PORT_RANGE (transport->port))
transport->port.min >= 65536 || transport->port.max >= 65536)
goto invalid_transport; goto invalid_transport;
}
} else if (g_str_has_prefix (split[i], "client_port=")) { } else if (g_str_has_prefix (split[i], "client_port=")) {
RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_CLIENT_PORT); RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_CLIENT_PORT);
parse_range (split[i] + 12, &transport->client_port); if (parse_range (split[i] + 12, &transport->client_port)) {
if (transport->client_port.min < 0 || if (!IS_VALID_PORT_RANGE (transport->client_port))
transport->client_port.min >= 65536 ||
transport->client_port.max >= 65536)
goto invalid_transport; goto invalid_transport;
}
} else if (g_str_has_prefix (split[i], "server_port=")) { } else if (g_str_has_prefix (split[i], "server_port=")) {
RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_SERVER_PORT); RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_SERVER_PORT);
parse_range (split[i] + 12, &transport->server_port); if (parse_range (split[i] + 12, &transport->server_port)) {
if (transport->server_port.min < 0 || if (!IS_VALID_PORT_RANGE (transport->server_port))
transport->server_port.min >= 65536 ||
transport->server_port.max >= 65536)
goto invalid_transport; goto invalid_transport;
}
} else if (g_str_has_prefix (split[i], "ssrc=")) { } else if (g_str_has_prefix (split[i], "ssrc=")) {
RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_SSRC); RTSP_TRANSPORT_PARAMETER_IS_UNIQUE (RTSP_TRANSPORT_SSRC);
transport->ssrc = strtoul (split[i] + 5, NULL, 16); transport->ssrc = strtoul (split[i] + 5, NULL, 16);