[#1534] Throws a length_error exception in case URL exceeds std::string max_size

This commit is contained in:
Emmanuel Milou
2009-06-03 10:41:50 -04:00
parent c72a826432
commit 47facc2eef
3 changed files with 20 additions and 6 deletions

View File

@ -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");
}
/************************************************************************************************/

View File

@ -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;

View File

@ -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