]> code.delx.au - pulseaudio/commitdiff
rtp: Fix rtp_port reading.
authorTanu Kaskinen <tanu.kaskinen@digia.com>
Thu, 29 Mar 2012 13:03:59 +0000 (16:03 +0300)
committerTanu Kaskinen <tanuk@iki.fi>
Tue, 23 Oct 2012 10:29:59 +0000 (13:29 +0300)
pa_atou() return value was not checked, and the cast of a
16-bit variable pointer to a 32-bit variable pointer could
corrupt cseq.

src/modules/rtp/rtsp_client.c

index 2c8b2dcf6d64112249a0c469643f9d19d871b6a9..90521fe638148e2bd2854a3a7d7b98dbbfea37aa 100644 (file)
@@ -143,9 +143,17 @@ static void headers_read(pa_rtsp_client *c) {
 
         /* Now parse out the server port component of the response. */
         while ((token = pa_split(c->transport, delimiters, &token_state))) {
-            if ((pc = strstr(token, "="))) {
+            if ((pc = strchr(token, '='))) {
                 if (0 == strncmp(token, "server_port", 11)) {
-                    pa_atou(pc+1, (uint32_t*)(&c->rtp_port));
+                    uint32_t p;
+
+                    if (pa_atou(pc + 1, &p) < 0 || p <= 0 || p > 0xffff) {
+                        pa_log("Invalid SETUP response (invalid server_port).");
+                        pa_xfree(token);
+                        return;
+                    }
+
+                    c->rtp_port = p;
                     pa_xfree(token);
                     break;
                 }