Limit the number of simultanious children
Make sure minidlna cannot fork more than 5 children, to avoid becoming a fork bomb. Reported-by: Rinat Ibragimov <ibragimovrinat@mail.ru>
This commit is contained in:
13
upnphttp.c
13
upnphttp.c
@ -78,6 +78,7 @@
|
||||
#include "tivo_utils.h"
|
||||
#include "tivo_commands.h"
|
||||
#include "clients.h"
|
||||
#include "process.h"
|
||||
|
||||
#include "sendfile.h"
|
||||
|
||||
@ -1574,8 +1575,8 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
||||
|
||||
#if USE_FORK
|
||||
pid_t newpid = 0;
|
||||
newpid = fork();
|
||||
if( newpid )
|
||||
newpid = process_fork();
|
||||
if( newpid > 0 )
|
||||
{
|
||||
CloseSocket_upnphttp(h);
|
||||
goto resized_error;
|
||||
@ -1716,7 +1717,7 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
|
||||
resized_error:
|
||||
sqlite3_free_table(result);
|
||||
#if USE_FORK
|
||||
if( !newpid )
|
||||
if( newpid == 0 )
|
||||
_exit(0);
|
||||
#endif
|
||||
}
|
||||
@ -1809,8 +1810,8 @@ SendResp_dlnafile(struct upnphttp *h, char *object)
|
||||
sqlite3_free_table(result);
|
||||
}
|
||||
#if USE_FORK
|
||||
newpid = fork();
|
||||
if( newpid )
|
||||
newpid = process_fork();
|
||||
if( newpid > 0 )
|
||||
{
|
||||
CloseSocket_upnphttp(h);
|
||||
goto error;
|
||||
@ -1951,7 +1952,7 @@ SendResp_dlnafile(struct upnphttp *h, char *object)
|
||||
CloseSocket_upnphttp(h);
|
||||
error:
|
||||
#if USE_FORK
|
||||
if( !newpid )
|
||||
if( newpid == 0 )
|
||||
_exit(0);
|
||||
#endif
|
||||
return;
|
||||
|
Reference in New Issue
Block a user