[pulseaudio-commits] 4 commits - src/modules

Peter Meerwald pmeerw at kemper.freedesktop.org
Thu Mar 9 12:52:26 UTC 2017


 src/modules/raop/raop-client.c |   50 ++++++++++++++++++++++++-----------------
 src/modules/raop/raop-sink.c   |   10 ++++----
 2 files changed, 36 insertions(+), 24 deletions(-)

New commits:
commit 2898a5188c8aea99f4b0e9492981d48099a499f4
Author: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
Date:   Wed Mar 8 15:57:22 2017 +0100

    raop: Error out on parsing server port component
    
    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>

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);
             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);

commit add5a175b618b082cbe6cb53d7c7bf397dc71060
Author: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
Date:   Tue Mar 7 15:44:06 2017 +0100

    raop: Log if pa_atoi() fails, latency is not used anyway
    
    Coverity ID: #1398152
    
    Signed-off-by: Peter Meerwald-Stadler <pmeerw at pmeerw.net>

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index e2cf04e..78f86a4 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1102,8 +1102,10 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
             pa_log_debug("RAOP: RECORD");
 
             alt = pa_xstrdup(pa_headerlist_gets(headers, "Audio-Latency"));
-            if (alt)
-                pa_atoi(alt, &latency);
+            if (alt) {
+                if (pa_atoi(alt, &latency) < 0)
+                    pa_log("Failed to parse audio latency");
+            }
 
             pa_raop_packet_buffer_reset(c->pbuf, c->seq);
 

commit 4cfd544f2117fa3afe19874c92b7d063c69c44c5
Author: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
Date:   Tue Mar 7 15:16:54 2017 +0100

    raop: Fix potential NULL dereference
    
    wath may be NULL, as suggested by Hajime Fujita
    Coverity ID: #1398156
    
    setting val = NULL is not needed
    
    Signed-off-by: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
    Cc: Hajime Fujita <crisp.fujita at nifty.com>

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index f23cf93..e2cf04e 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -1229,7 +1229,7 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_st
             const char *current = NULL;
             char space[] = " ";
             char *token, *ath = NULL;
-            char *publ, *wath, *mth, *val;
+            char *publ, *wath, *mth = NULL, *val;
             char *realm = NULL, *nonce = NULL, *response = NULL;
             char comma[] = ",";
 
@@ -1244,19 +1244,18 @@ static void rtsp_auth_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_st
                     goto fail;
                 }
 
-                if (wath)
+                if (wath) {
                     mth = pa_split(wath, space, &current);
-                while ((token = pa_split(wath, comma, &current))) {
-                    val = NULL;
-                    if ((val = strstr(token, "="))) {
-                        if (NULL == realm && val > strstr(token, "realm"))
-                            realm = pa_xstrdup(val + 2);
-                        else if (NULL == nonce && val > strstr(token, "nonce"))
-                            nonce = pa_xstrdup(val + 2);
-                        val = NULL;
-                    }
+                    while ((token = pa_split(wath, comma, &current))) {
+                        if ((val = strstr(token, "="))) {
+                            if (NULL == realm && val > strstr(token, "realm"))
+                                realm = pa_xstrdup(val + 2);
+                            else if (NULL == nonce && val > strstr(token, "nonce"))
+                                nonce = pa_xstrdup(val + 2);
+                        }
 
-                    pa_xfree(token);
+                        pa_xfree(token);
+                    }
                 }
 
                 if (pa_safe_streq(mth, "Basic") && realm) {

commit a8ce3ef844f460b1769e6472694ca4cf049dfd55
Author: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
Date:   Tue Mar 7 14:43:48 2017 +0100

    raop: Fix potential dereference after NULL check
    
    Coverity ID: #1398157
    
    Signed-off-by: Peter Meerwald-Stadler <pmeerw at pmeerw.net>

diff --git a/src/modules/raop/raop-sink.c b/src/modules/raop/raop-sink.c
index c5ff8b9..4ca625f 100644
--- a/src/modules/raop/raop-sink.c
+++ b/src/modules/raop/raop-sink.c
@@ -246,10 +246,12 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
 
                     if (u->rtpoll_item) {
                         pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, &nbfds);
-                        for (i = 0; i < nbfds; i++) {
-                            if (pollfd && pollfd->fd >= 0)
-                               pa_close(pollfd->fd);
-                            pollfd++;
+                        if (pollfd) {
+                            for (i = 0; i < nbfds; i++) {
+                                if (pollfd->fd >= 0)
+                                   pa_close(pollfd->fd);
+                                pollfd++;
+                            }
                         }
                         pa_rtpoll_item_free(u->rtpoll_item);
                         u->rtpoll_item = NULL;



More information about the pulseaudio-commits mailing list