mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
[#1534] Throws a length_error exception in case URL exceeds std::string max_size
This commit is contained in:
@ -2245,12 +2245,18 @@ mod_on_rx_request ( pjsip_rx_data *rdata )
|
||||
|
||||
header_value = fetch_header_value ( rdata->msg_info.msg, Manager::instance().getConfigString ( HOOKS, URLHOOK_SIP_FIELD ) );
|
||||
|
||||
if ( header_value!="" )
|
||||
{
|
||||
urlhook->addAction ( header_value,
|
||||
if (header_value.size () < header_value.max_size())
|
||||
{
|
||||
if ( header_value!="" )
|
||||
{
|
||||
urlhook->addAction ( header_value,
|
||||
Manager::instance().getConfigString ( HOOKS, URLHOOK_COMMAND ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
throw length_error ("Url exceeds std::string max_size\n");
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************************************/
|
||||
|
||||
|
@ -36,10 +36,16 @@ void HookManagerTest::testAddAction (){
|
||||
|
||||
int status;
|
||||
|
||||
status = urlhook->addAction ("www.google.ca", "gnome-www-browser");
|
||||
status = urlhook->addAction ("www.google.ca", "x-www-browser");
|
||||
CPPUNIT_ASSERT (status == 0);
|
||||
}
|
||||
|
||||
void HookManagerTest::testLargeUrl (){
|
||||
|
||||
std::string url;
|
||||
std::cout << url.max_size() << std::endl;
|
||||
}
|
||||
|
||||
void HookManagerTest::tearDown(){
|
||||
// Delete the hook manager object
|
||||
delete urlhook; urlhook=0;
|
||||
|
@ -43,6 +43,7 @@ class HookManagerTest : public CppUnit::TestCase {
|
||||
*/
|
||||
CPPUNIT_TEST_SUITE (HookManagerTest);
|
||||
CPPUNIT_TEST (testAddAction);
|
||||
CPPUNIT_TEST (testLargeUrl);
|
||||
CPPUNIT_TEST_SUITE_END ();
|
||||
|
||||
public:
|
||||
@ -56,6 +57,7 @@ class HookManagerTest : public CppUnit::TestCase {
|
||||
|
||||
void testAddAction ();
|
||||
|
||||
void testLargeUrl ();
|
||||
/*
|
||||
* Code factoring - Common resources can be released here.
|
||||
* This method is called by unitcpp after each test
|
||||
|
Reference in New Issue
Block a user