From 6064dd1173f1d0b0afbe3a44ab6ef08e9043e78a Mon Sep 17 00:00:00 2001
From: Tyler Wear <twear@codeaurora.org>
Date: Tue, 10 Dec 2013 10:42:32 -0800
Subject: [PATCH 1/1] certification-fixes

---
 linux/minidlna.init.d.script.tmpl |   14 +++-----------
 minissdp.c                   |    1 +
 upnphttp.c                   |    9 ++++++++-
 3 files changed, 12 insertions(+), 12 deletions(-)
 mode change 100644 => 100755 linux/minidlna.init.d.script.tmpl
 mode change 100644 => 100755 minissdp.c
 mode change 100644 => 100755 upnphttp.c

diff --git a/linux/minidlna.init.d.script.tmpl b/linux/minidlna.init.d.script.tmpl
old mode 100644
new mode 100755
index 744c4be..80f8de1
--- a/linux/minidlna.init.d.script.tmpl
+++ b/linux/minidlna.init.d.script.tmpl
@@ -21,26 +21,18 @@
 MINIDLNA=/usr/sbin/minidlnad
 PIDFILE=/var/run/minidlna/minidlna.pid
 CONF=/etc/minidlna.conf
-ARGS="-f $CONF"
+ARGS="-f $CONF -R"

 test -f $MINIDLNA || exit 0

-. /lib/lsb/init-functions
-
 case "$1" in
-start)  log_daemon_msg "Starting minidlna" "minidlna"
-        start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $MINIDLNA -- $ARGS $LSBNAMES
-        log_end_msg $?
+start)  start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $MINIDLNA -- $ARGS $LSBNAMES
         ;;
-stop)   log_daemon_msg "Stopping minidlna" "minidlna"
-        start-stop-daemon --stop --quiet --pidfile $PIDFILE
-        log_end_msg $?
+stop)   start-stop-daemon --stop --quiet --pidfile $PIDFILE
         ;;
 restart|reload|force-reload)
-        log_daemon_msg "Restarting minidlna" "minidlna"
         start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE
         start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $MINIDLNA -- $ARGS $LSBNAMES
-        log_end_msg $?
         ;;
 status)
         status_of_proc -p $PIDFILE $MINIDLNA minidlna && exit 0 || exit $?
diff --git a/minissdp.c b/minissdp.c
old mode 100644
new mode 100755
index d754bdb..c07ca10
--- a/minissdp.c
+++ b/minissdp.c
@@ -294,6 +294,7 @@ SendSSDPNotifies(int s, const char *host, unsigned short port,
			DPRINTF(E_MAXDEBUG, L_SSDP, "Sending ssdp:alive\n");
			n = sendto(s, bufr, l, 0,
				(struct sockaddr *)&sockname, sizeof(struct sockaddr_in));
+			_usleep(20000);
			if (n < 0)
				DPRINTF(E_ERROR, L_SSDP, "sendto(udp_notify=%d, %s): %s\n", s, host, strerror(errno));
			i++;
diff --git a/upnphttp.c b/upnphttp.c
old mode 100644
new mode 100755
index 2269472..334df3a
--- a/upnphttp.c
+++ b/upnphttp.c
@@ -1881,9 +1881,16 @@ SendResp_dlnafile(struct upnphttp *h, char *object)
		{
			h->req_RangeEnd = size - 1;
		}
-		if( (h->req_RangeStart > h->req_RangeEnd) || (h->req_RangeStart < 0) )
+		if( h->req_RangeStart < 0 )
		{
			DPRINTF(E_WARN, L_HTTP, "Specified range was invalid!\n");
+			Send416(h);
+			close(sendfh);
+			goto error;
+		}
+		if( h->req_RangeStart > h->req_RangeEnd )
+		{
+			DPRINTF(E_WARN, L_HTTP, "Bad Request!\n");
			Send400(h);
			close(sendfh);
			goto error;
--
1.7.8.3

