From 820486ad95f63c9c9497181899736a743d914dec Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Tue, 26 Jun 2018 22:07:13 +0100 Subject: [PATCH 1/6] Add a hint for the mosquitto library. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 23b4baac..4c5f50dd 100644 --- a/configure.ac +++ b/configure.ac @@ -320,7 +320,7 @@ AC_ARG_WITH(mqtt-client, [ --with-mqtt-client = include support for the native HAS_MQTT=1 AC_DEFINE([HAVE_MQTT], 1, [Needed by the compiler.]) AC_DEFINE([CONFIG_MQTT], 1, [Needed by the compiler.]) - AC_CHECK_LIB([mosquitto], [mosquitto_lib_init], , AC_MSG_ERROR(MQTT support requires the mosquitto library!)) + AC_CHECK_LIB([mosquitto], [mosquitto_lib_init], , AC_MSG_ERROR(MQTT support requires the mosquitto library -- libmosquitto-dev suggested!)) AC_CHECK_HEADERS([mosquitto.h],,[AC_MSG_ERROR([ header missing])]) AC_DEFINE([HAVE_MOSQUITTO],[1],[Define to 1 if you have the mosquitto library]) From 7aee31fb7e7da28350b09e8d40c1760563bac416 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Fri, 29 Jun 2018 22:59:19 +0100 Subject: [PATCH 2/6] Reduce the rate at which resends are requests to make them less, uh, insistent --- player.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/player.c b/player.c index 3a2b8dc0..f713dce8 100644 --- a/player.c +++ b/player.c @@ -607,10 +607,11 @@ void player_put_packet(seq_t seqno, uint32_t actual_timestamp, int64_t timestamp int j; for (j = 1; j <= number_of_resend_attempts; j++) { // check j times, after a short period of has elapsed, assuming 352 frames per packet - - int back_step = resend_interval * j; + // the higher the step_exponent, the less it will try. 1 means it will try very hard. 2.0 seems good. + float step_exponent = 2.0; + int back_step = (int)(resend_interval * pow(j,step_exponent)); int k; - for (k = -2; k <= 2; k++) { + for (k = -1; k <= 1; k++) { if ((back_step + k) < seq_diff(conn->ab_read, conn->ab_write, conn->ab_read)) { // if it's within the range of frames in use... @@ -622,7 +623,7 @@ void player_put_packet(seq_t seqno, uint32_t actual_timestamp, int64_t timestamp j)) { // prevent multiple requests from the same level of lookback check_buf->resend_level = j; if (config.disable_resend_requests == 0) { - if ((back_step + k + resend_interval) >= + if (((int)(resend_interval * pow(j+1,step_exponent)) + k) >= seq_diff(conn->ab_read, conn->ab_write, conn->ab_read)) debug(3, "Last-ditch (#%d) resend request for packet %u in range %u to %u. " "Looking back %d packets.", From 8ae8fcbfba9c696f82ea942003f31556aee0be14 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Fri, 29 Jun 2018 22:59:42 +0100 Subject: [PATCH 3/6] Reduce the rate at which resends are requests to make them less, uh, insistent --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4c5f50dd..977d8e74 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.50]) -AC_INIT([shairport-sync], [3.2d64], [mikebrady@eircom.net]) +AC_INIT([shairport-sync], [3.2d65], [mikebrady@eircom.net]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([shairport.c]) AC_CONFIG_HEADERS([config.h]) From c7a3c19fa5f2c85045e195392307c9a231e40c64 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Fri, 29 Jun 2018 18:32:47 -0400 Subject: [PATCH 4/6] Update RELEASENOTES.md --- RELEASENOTES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 32de93f1..a76ec2d1 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,3 +1,8 @@ +Version 3.2.d65 +==== +**Modification** +* The algorithm for generating resend requests has been made somewhat more gentle -- a little less insistent. + Version 3.2.d64 ==== **Enhancement** From d49333a81a84182413ddd476a89829c79dbc41e5 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Sat, 30 Jun 2018 15:47:54 +0100 Subject: [PATCH 5/6] Do some very elementary checking of an ANNOUNCE packet -- check for content length over 1k and for negative remaining line lengths... --- rtsp.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/rtsp.c b/rtsp.c index 84c9ae20..b66e8954 100644 --- a/rtsp.c +++ b/rtsp.c @@ -714,10 +714,9 @@ static void handle_options(rtsp_conn_info *conn, __attribute__((unused)) rtsp_me rtsp_message *resp) { debug(3, "Connection %d: OPTIONS", conn->connection_number); resp->respcode = 200; - msg_add_header(resp, "Public", - "ANNOUNCE, SETUP, RECORD, " - "PAUSE, FLUSH, TEARDOWN, " - "OPTIONS, GET_PARAMETER, SET_PARAMETER"); + msg_add_header(resp, "Public", "ANNOUNCE, SETUP, RECORD, " + "PAUSE, FLUSH, TEARDOWN, " + "OPTIONS, GET_PARAMETER, SET_PARAMETER"); } static void handle_teardown(rtsp_conn_info *conn, __attribute__((unused)) rtsp_message *req, @@ -849,11 +848,10 @@ static void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message * } char resphdr[256] = ""; - snprintf(resphdr, sizeof(resphdr), - "RTP/AVP/" - "UDP;unicast;interleaved=0-1;mode=record;control_port=%d;" - "timing_port=%d;server_" - "port=%d", + snprintf(resphdr, sizeof(resphdr), "RTP/AVP/" + "UDP;unicast;interleaved=0-1;mode=record;control_port=%d;" + "timing_port=%d;server_" + "port=%d", conn->local_control_port, conn->local_timing_port, conn->local_audio_port); msg_add_header(resp, "Transport", resphdr); @@ -1246,9 +1244,9 @@ void *metadata_thread_function(__attribute__((unused)) void *ignore) { metadata_hub_process_metadata(pack.type, pack.code, pack.data, pack.length); #endif #ifdef HAVE_MQTT - if(config.mqtt_enabled){ - mqtt_process_metadata(pack.type, pack.code, pack.data, pack.length); - } + if (config.mqtt_enabled) { + mqtt_process_metadata(pack.type, pack.code, pack.data, pack.length); + } #endif } if (pack.carrier) @@ -1376,7 +1374,7 @@ static void handle_set_parameter(rtsp_conn_info *conn, rtsp_message *req, rtsp_m char *ct = msg_get_header(req, "Content-Type"); if (ct) { - // debug(2, "SET_PARAMETER Content-Type:\"%s\".", ct); +// debug(2, "SET_PARAMETER Content-Type:\"%s\".", ct); #ifdef CONFIG_METADATA // It seems that the rtptime of the message is used as a kind of an ID that @@ -1513,10 +1511,20 @@ static void handle_announce(rtsp_conn_info *conn, rtsp_message *req, rtsp_messag char *pmaxlatency = NULL; char *cp = req->content; int cp_left = req->contentlength; + if (cp_left > 1024) { + debug(1, "Error -- RTSP conversation thread %d ANNOUNCE content length is strange, at %d.", + conn->connection_number, cp_left); + goto out; + } char *next; while (cp_left && cp) { next = nextline(cp, cp_left); cp_left -= next - cp; + if (cp_left < 0) { + debug(1, "Error -- RTSP conversation thread %d ANNOUNCE content remaining is negative.", + conn->connection_number); + goto out; + } if (!strncmp(cp, "a=fmtp:", 7)) pfmtp = cp + 7; @@ -1901,9 +1909,8 @@ static void *rtsp_conversation_thread_func(void *pconn) { if (strcmp(req->method, "OPTIONS") != 0) // the options message is very common, so don't log it until level 3 debug_level = 2; - debug(debug_level, - "RTSP thread %d received an RTSP Packet of type \"%s\":", conn->connection_number, - req->method), + debug(debug_level, "RTSP thread %d received an RTSP Packet of type \"%s\":", + conn->connection_number, req->method), debug_print_msg_headers(debug_level, req); resp = msg_init(); resp->respcode = 400; From 2a5495a7db4777ba0c979c91719624b70d86d368 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Sat, 30 Jun 2018 10:52:36 -0400 Subject: [PATCH 6/6] Update RELEASENOTES.md --- RELEASENOTES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index a76ec2d1..a5495253 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -3,6 +3,10 @@ Version 3.2.d65 **Modification** * The algorithm for generating resend requests has been made somewhat more gentle -- a little less insistent. + +**Bug Chasing** +* Some very elementary bounds checking on the ANNOUNCE packet is performed: that it is 1024 bytes or less in size and that line lengths remaining after parsing do not turn negative when they should remain positive or be exactly zero. + Version 3.2.d64 ==== **Enhancement**