* Fix a potential segfault on requests for existing objects with no path. (Thanks Dominic)
This commit is contained in:
27
upnphttp.c
27
upnphttp.c
@ -695,6 +695,7 @@ SendResp_presentation(struct upnphttp * h)
|
|||||||
#endif
|
#endif
|
||||||
BuildResp_upnphttp(h, body, l);
|
BuildResp_upnphttp(h, body, l);
|
||||||
SendResp_upnphttp(h);
|
SendResp_upnphttp(h);
|
||||||
|
CloseSocket_upnphttp(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ProcessHTTPPOST_upnphttp()
|
/* ProcessHTTPPOST_upnphttp()
|
||||||
@ -949,7 +950,6 @@ ProcessHttpQuery_upnphttp(struct upnphttp * h)
|
|||||||
else if(strncmp(HttpUrl, "/MediaItems/", 12) == 0)
|
else if(strncmp(HttpUrl, "/MediaItems/", 12) == 0)
|
||||||
{
|
{
|
||||||
SendResp_dlnafile(h, HttpUrl+12);
|
SendResp_dlnafile(h, HttpUrl+12);
|
||||||
CloseSocket_upnphttp(h);
|
|
||||||
}
|
}
|
||||||
else if(strncmp(HttpUrl, "/Thumbnails/", 12) == 0)
|
else if(strncmp(HttpUrl, "/Thumbnails/", 12) == 0)
|
||||||
{
|
{
|
||||||
@ -958,7 +958,6 @@ ProcessHttpQuery_upnphttp(struct upnphttp * h)
|
|||||||
else if(strncmp(HttpUrl, "/AlbumArt/", 10) == 0)
|
else if(strncmp(HttpUrl, "/AlbumArt/", 10) == 0)
|
||||||
{
|
{
|
||||||
SendResp_albumArt(h, HttpUrl+10);
|
SendResp_albumArt(h, HttpUrl+10);
|
||||||
CloseSocket_upnphttp(h);
|
|
||||||
}
|
}
|
||||||
#ifdef TIVO_SUPPORT
|
#ifdef TIVO_SUPPORT
|
||||||
else if(strncmp(HttpUrl, "/TiVoConnect", 12) == 0)
|
else if(strncmp(HttpUrl, "/TiVoConnect", 12) == 0)
|
||||||
@ -986,22 +985,18 @@ ProcessHttpQuery_upnphttp(struct upnphttp * h)
|
|||||||
else if(strncmp(HttpUrl, "/Resized/", 9) == 0)
|
else if(strncmp(HttpUrl, "/Resized/", 9) == 0)
|
||||||
{
|
{
|
||||||
SendResp_resizedimg(h, HttpUrl+9);
|
SendResp_resizedimg(h, HttpUrl+9);
|
||||||
CloseSocket_upnphttp(h);
|
|
||||||
}
|
}
|
||||||
else if(strncmp(HttpUrl, "/icons/", 7) == 0)
|
else if(strncmp(HttpUrl, "/icons/", 7) == 0)
|
||||||
{
|
{
|
||||||
SendResp_icon(h, HttpUrl+7);
|
SendResp_icon(h, HttpUrl+7);
|
||||||
CloseSocket_upnphttp(h);
|
|
||||||
}
|
}
|
||||||
else if(strncmp(HttpUrl, "/Captions/", 10) == 0)
|
else if(strncmp(HttpUrl, "/Captions/", 10) == 0)
|
||||||
{
|
{
|
||||||
SendResp_caption(h, HttpUrl+10);
|
SendResp_caption(h, HttpUrl+10);
|
||||||
CloseSocket_upnphttp(h);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(HttpUrl, "/") == 0)
|
else if(strcmp(HttpUrl, "/") == 0)
|
||||||
{
|
{
|
||||||
SendResp_presentation(h);
|
SendResp_presentation(h);
|
||||||
CloseSocket_upnphttp(h);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1356,6 +1351,7 @@ SendResp_icon(struct upnphttp * h, char * icon)
|
|||||||
if( h->req_command != EHead )
|
if( h->req_command != EHead )
|
||||||
send_data(h, data, size, 0);
|
send_data(h, data, size, 0);
|
||||||
}
|
}
|
||||||
|
CloseSocket_upnphttp(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1421,6 +1417,7 @@ SendResp_albumArt(struct upnphttp * h, char * object)
|
|||||||
send_file(h, fd, 0, size-1);
|
send_file(h, fd, 0, size-1);
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
CloseSocket_upnphttp(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1470,6 +1467,7 @@ SendResp_caption(struct upnphttp * h, char * object)
|
|||||||
send_file(h, fd, 0, size-1);
|
send_file(h, fd, 0, size-1);
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
CloseSocket_upnphttp(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1588,7 +1586,10 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
|||||||
pid_t newpid = 0;
|
pid_t newpid = 0;
|
||||||
newpid = fork();
|
newpid = fork();
|
||||||
if( newpid )
|
if( newpid )
|
||||||
|
{
|
||||||
|
CloseSocket_upnphttp(h);
|
||||||
goto resized_error;
|
goto resized_error;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
file_path = result[2];
|
file_path = result[2];
|
||||||
resolution = result[3];
|
resolution = result[3];
|
||||||
@ -1739,7 +1740,8 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
|||||||
image_free(imsrc);
|
image_free(imsrc);
|
||||||
if( imdst )
|
if( imdst )
|
||||||
image_free(imdst);
|
image_free(imdst);
|
||||||
resized_error:
|
CloseSocket_upnphttp(h);
|
||||||
|
resized_error:
|
||||||
sqlite3_free_table(result);
|
sqlite3_free_table(result);
|
||||||
#if USE_FORK
|
#if USE_FORK
|
||||||
if( !newpid )
|
if( !newpid )
|
||||||
@ -1781,7 +1783,7 @@ SendResp_dlnafile(struct upnphttp * h, char * object)
|
|||||||
Send500(h);
|
Send500(h);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( !rows )
|
if( !rows || !result[3] )
|
||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_HTTP, "%s not found, responding ERROR 404\n", object);
|
DPRINTF(E_WARN, L_HTTP, "%s not found, responding ERROR 404\n", object);
|
||||||
sqlite3_free_table(result);
|
sqlite3_free_table(result);
|
||||||
@ -1830,7 +1832,10 @@ SendResp_dlnafile(struct upnphttp * h, char * object)
|
|||||||
#if USE_FORK
|
#if USE_FORK
|
||||||
newpid = fork();
|
newpid = fork();
|
||||||
if( newpid )
|
if( newpid )
|
||||||
return;
|
{
|
||||||
|
CloseSocket_upnphttp(h);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DPRINTF(E_INFO, L_HTTP, "Serving DetailID: %lld [%s]\n", id, last_file.path);
|
DPRINTF(E_INFO, L_HTTP, "Serving DetailID: %lld [%s]\n", id, last_file.path);
|
||||||
@ -1966,10 +1971,10 @@ SendResp_dlnafile(struct upnphttp * h, char * object)
|
|||||||
}
|
}
|
||||||
close(sendfh);
|
close(sendfh);
|
||||||
|
|
||||||
error:
|
CloseSocket_upnphttp(h);
|
||||||
|
error:
|
||||||
#if USE_FORK
|
#if USE_FORK
|
||||||
if( !newpid )
|
if( !newpid )
|
||||||
_exit(0);
|
_exit(0);
|
||||||
#endif
|
#endif
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user