Apparently URLs contain exploits these days.

Thanks djpohly for fixing.
This commit is contained in:
phantom
2013-06-30 00:12:31 +02:00
parent 6c59100c31
commit 39c7613802
+23 -3
View File
@@ -12,6 +12,8 @@
#include "archutils/Unix/AssertionHandler.h"
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#if defined(CRASH_HANDLER)
#include "archutils/Unix/CrashHandler.h"
@@ -200,9 +202,27 @@ void ArchHooks_Unix::Init()
bool ArchHooks_Unix::GoToURL( RString sUrl )
{
RString command = "xdg-open " + sUrl;
int result = system( command.c_str() );
return result != -1 && WEXITSTATUS( result ) == 0;
int status;
pid_t p = fork();
if ( p == -1 )
{
// Call to fork failed
return false;
}
else if ( p == 0 )
{
// Child
const char * const argv[] = { "xdg-open", sUrl.c_str(), NULL };
execv( "/usr/bin/xdg-open", const_cast<char * const *>( argv ));
// If we reach here, the call to execvp failed
exit( 1 );
}
else
{
// Parent
waitpid( p, &status, 0 );
return WEXITSTATUS( status ) == 0;
}
}
#ifndef _CS_GNU_LIBC_VERSION