* Improve error checking for DLNA CTT compliance.
This commit is contained in:
parent
a40b085d07
commit
996b373f83
64
upnphttp.c
64
upnphttp.c
@ -248,12 +248,12 @@ ParseHttpHeaders(struct upnphttp * h)
|
|||||||
h->req_NTLen = n;
|
h->req_NTLen = n;
|
||||||
}
|
}
|
||||||
/* Timeout: Seconds-nnnn */
|
/* Timeout: Seconds-nnnn */
|
||||||
/* TIMEOUT
|
/* TIMEOUT
|
||||||
Recommended. Requested duration until subscription expires,
|
Recommended. Requested duration until subscription expires,
|
||||||
either number of seconds or infinite. Recommendation
|
either number of seconds or infinite. Recommendation
|
||||||
by a UPnP Forum working committee. Defined by UPnP vendor.
|
by a UPnP Forum working committee. Defined by UPnP vendor.
|
||||||
Consists of the keyword "Second-" followed (without an
|
Consists of the keyword "Second-" followed (without an
|
||||||
intervening space) by either an integer or the keyword "infinite". */
|
intervening space) by either an integer or the keyword "infinite". */
|
||||||
else if(strncasecmp(line, "Timeout", 7)==0)
|
else if(strncasecmp(line, "Timeout", 7)==0)
|
||||||
{
|
{
|
||||||
p = colon + 1;
|
p = colon + 1;
|
||||||
@ -444,6 +444,14 @@ intervening space) by either an integer or the keyword "infinite". */
|
|||||||
{
|
{
|
||||||
h->reqflags |= FLAG_REALTIMEINFO;
|
h->reqflags |= FLAG_REALTIMEINFO;
|
||||||
}
|
}
|
||||||
|
else if(strncasecmp(line, "getAvailableSeekRange.dlna.org", 21)==0)
|
||||||
|
{
|
||||||
|
p = colon + 1;
|
||||||
|
while(isspace(*p))
|
||||||
|
p++;
|
||||||
|
if( (*p != '1') || !isspace(p[1]) )
|
||||||
|
h->reqflags |= FLAG_INVALID_REQ;
|
||||||
|
}
|
||||||
else if(strncasecmp(line, "transferMode.dlna.org", 21)==0)
|
else if(strncasecmp(line, "transferMode.dlna.org", 21)==0)
|
||||||
{
|
{
|
||||||
p = colon + 1;
|
p = colon + 1;
|
||||||
@ -685,7 +693,7 @@ SendResp_presentation(struct upnphttp * h)
|
|||||||
v = sql_get_int_field(db, "SELECT count(*) from DETAILS where MIME glob 'v*'");
|
v = sql_get_int_field(db, "SELECT count(*) from DETAILS where MIME glob 'v*'");
|
||||||
p = sql_get_int_field(db, "SELECT count(*) from DETAILS where MIME glob 'i*'");
|
p = sql_get_int_field(db, "SELECT count(*) from DETAILS where MIME glob 'i*'");
|
||||||
l = snprintf(body, sizeof(body),
|
l = snprintf(body, sizeof(body),
|
||||||
"<HTML><HEAD><TITLE>" SERVER_NAME "</TITLE></HEAD>"
|
"<HTML><HEAD><TITLE>" SERVER_NAME " " MINIDLNA_VERSION "</TITLE></HEAD>"
|
||||||
"<BODY><div style=\"text-align: center\">"
|
"<BODY><div style=\"text-align: center\">"
|
||||||
"<h3>" SERVER_NAME " status</h3>"
|
"<h3>" SERVER_NAME " status</h3>"
|
||||||
"Audio files: %d<br>"
|
"Audio files: %d<br>"
|
||||||
@ -740,15 +748,8 @@ ProcessHTTPSubscribe_upnphttp(struct upnphttp * h, const char * path)
|
|||||||
DPRINTF(E_DEBUG, L_HTTP, "Callback '%.*s' Timeout=%d\n",
|
DPRINTF(E_DEBUG, L_HTTP, "Callback '%.*s' Timeout=%d\n",
|
||||||
h->req_CallbackLen, h->req_Callback, h->req_Timeout);
|
h->req_CallbackLen, h->req_Callback, h->req_Timeout);
|
||||||
DPRINTF(E_DEBUG, L_HTTP, "SID '%.*s'\n", h->req_SIDLen, h->req_SID);
|
DPRINTF(E_DEBUG, L_HTTP, "SID '%.*s'\n", h->req_SIDLen, h->req_SID);
|
||||||
if(!h->req_NT) {
|
if((!h->req_Callback && !h->req_SID) ||
|
||||||
static const char err400str[] =
|
strncmp(h->req_NT, "upnp:event", h->req_NTLen) != 0) {
|
||||||
"<html><body>Bad request</body></html>";
|
|
||||||
BuildResp2_upnphttp(h, 400, "Bad Request",
|
|
||||||
err400str, sizeof(err400str) - 1);
|
|
||||||
SendResp_upnphttp(h);
|
|
||||||
CloseSocket_upnphttp(h);
|
|
||||||
} else if((!h->req_Callback && !h->req_SID) ||
|
|
||||||
strncmp(h->req_NT, "upnp:event", h->req_NTLen) != 0) {
|
|
||||||
/* Missing or invalid CALLBACK : 412 Precondition Failed.
|
/* Missing or invalid CALLBACK : 412 Precondition Failed.
|
||||||
* If CALLBACK header is missing or does not contain a valid HTTP URL,
|
* If CALLBACK header is missing or does not contain a valid HTTP URL,
|
||||||
* the publisher must respond with HTTP error 412 Precondition Failed*/
|
* the publisher must respond with HTTP error 412 Precondition Failed*/
|
||||||
@ -759,18 +760,23 @@ ProcessHTTPSubscribe_upnphttp(struct upnphttp * h, const char * path)
|
|||||||
/* - add to the subscriber list
|
/* - add to the subscriber list
|
||||||
* - respond HTTP/x.x 200 OK
|
* - respond HTTP/x.x 200 OK
|
||||||
* - Send the initial event message */
|
* - Send the initial event message */
|
||||||
/* Server:, SID:; Timeout: Second-(xx|infinite) */
|
/* Server:, SID:; Timeout: Second-(xx|infinite) */
|
||||||
if(h->req_Callback) {
|
if(h->req_Callback) {
|
||||||
sid = upnpevents_addSubscriber(path, h->req_Callback,
|
if(!h->req_NT || strncmp(h->req_NT, "upnp:event", h->req_NTLen) != 0) {
|
||||||
h->req_CallbackLen, h->req_Timeout);
|
BuildResp2_upnphttp(h, 400, "Bad Request",
|
||||||
h->respflags = FLAG_TIMEOUT;
|
"<html><body>Bad request</body></html>", 37);
|
||||||
if(sid) {
|
} else {
|
||||||
DPRINTF(E_DEBUG, L_HTTP, "generated sid=%s\n", sid);
|
sid = upnpevents_addSubscriber(path, h->req_Callback,
|
||||||
h->respflags |= FLAG_SID;
|
h->req_CallbackLen, h->req_Timeout);
|
||||||
h->req_SID = sid;
|
h->respflags = FLAG_TIMEOUT;
|
||||||
h->req_SIDLen = strlen(sid);
|
if(sid) {
|
||||||
|
DPRINTF(E_DEBUG, L_HTTP, "generated sid=%s\n", sid);
|
||||||
|
h->respflags |= FLAG_SID;
|
||||||
|
h->req_SID = sid;
|
||||||
|
h->req_SIDLen = strlen(sid);
|
||||||
|
}
|
||||||
|
BuildResp_upnphttp(h, 0, 0);
|
||||||
}
|
}
|
||||||
BuildResp_upnphttp(h, 0, 0);
|
|
||||||
} else {
|
} else {
|
||||||
/* subscription renew */
|
/* subscription renew */
|
||||||
/* Invalid SID
|
/* Invalid SID
|
||||||
@ -1589,14 +1595,15 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
|||||||
if( saveptr )
|
if( saveptr )
|
||||||
saveptr = strchr(saveptr, '?');
|
saveptr = strchr(saveptr, '?');
|
||||||
path = saveptr ? saveptr + 1 : object;
|
path = saveptr ? saveptr + 1 : object;
|
||||||
item = strtok_r(path, "&,", &saveptr);
|
for( item = strtok_r(path, "&,", &saveptr); item != NULL; item = strtok_r(NULL, "&,", &saveptr) )
|
||||||
while( item != NULL )
|
|
||||||
{
|
{
|
||||||
#ifdef TIVO_SUPPORT
|
#ifdef TIVO_SUPPORT
|
||||||
decodeString(item, 1);
|
decodeString(item, 1);
|
||||||
#endif
|
#endif
|
||||||
val = item;
|
val = item;
|
||||||
key = strsep(&val, "=");
|
key = strsep(&val, "=");
|
||||||
|
if( !val )
|
||||||
|
continue;
|
||||||
DPRINTF(E_DEBUG, L_GENERAL, "%s: %s\n", key, val);
|
DPRINTF(E_DEBUG, L_GENERAL, "%s: %s\n", key, val);
|
||||||
if( strcasecmp(key, "width") == 0 )
|
if( strcasecmp(key, "width") == 0 )
|
||||||
{
|
{
|
||||||
@ -1616,7 +1623,6 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
|||||||
{
|
{
|
||||||
pixelshape = val;
|
pixelshape = val;
|
||||||
} */
|
} */
|
||||||
item = strtok_r(NULL, "&,", &saveptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_FORK
|
#if USE_FORK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user