[pulseaudio-discuss] [PATCH 4/8] raop: Error out on parsing server port component

Georg Chini georg at chini.tk
Thu Mar 9 06:53:16 UTC 2017


On 08.03.2017 16:09, Peter Meerwald-Stadler wrote:
> don't ignore server port parsing errors as suggested by Hajime Fujita
>
> Signed-off-by: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
> Cc: Hajime Fujita <crisp.fujita at nifty.com>
> ---
>   src/modules/raop/raop-client.c | 21 +++++++++++++++------
>   1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
> index 78f86a4..ae950f7 100644
> --- a/src/modules/raop/raop-client.c
> +++ b/src/modules/raop/raop-client.c
> @@ -988,7 +988,7 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
>               pa_socket_client *sc = NULL;
>               uint32_t sport = DEFAULT_UDP_AUDIO_PORT;
>               uint32_t cport =0, tport = 0;
> -            char *ajs, *token, *pc;
> +            char *ajs, *token, *pc, *trs;
>               const char *token_state = NULL;
>               char delimiters[] = ";";
>   
> @@ -1031,17 +1031,21 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
>                   pa_socket_client_unref(sc);
>                   sc = NULL;
>               } else if (c->protocol == PA_RAOP_PROTOCOL_UDP) {
> -                char *trs = pa_xstrdup(pa_headerlist_gets(headers, "Transport"));
> +                trs = pa_xstrdup(pa_headerlist_gets(headers, "Transport"));
>   
>                   if (trs) {
>                       /* Now parse out the server port component of the response. */
>                       while ((token = pa_split(trs, delimiters, &token_state))) {
>                           if ((pc = strstr(token, "="))) {
>                               *pc = 0;
> -                            if (pa_streq(token, "control_port"))
> -                                (void) pa_atou(pc + 1, &cport);
> -                            if (pa_streq(token, "timing_port"))
> -                                (void) pa_atou(pc + 1, &tport);
> +                            if (pa_streq(token, "control_port")) {
> +                                if (pa_atou(pc + 1, &cport) < 0)
> +                                    goto setup_error_parse;
> +                            }
> +                            if (pa_streq(token, "timing_port")) {
> +                                if (pa_atou(pc + 1, &tport) < 0)
> +                                    goto setup_error_parse;
> +                            }
>                               *pc = '=';
>                           }
>                           pa_xfree(token);
> @@ -1072,6 +1076,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
>               pa_xfree(ajs);

You need to free trs here as well.

>               break;
>   
> +        setup_error_parse:
> +            pa_log("Failed parsing server port components");
> +            pa_xfree(token);
> +            pa_xfree(trs);
> +            /* fall-thru */
>           setup_error:
>               if (c->tcp_sfd >= 0)
>                   pa_close(c->tcp_sfd);




More information about the pulseaudio-discuss mailing list