From 5f02386838c5b95a8d9d218922db21d2b2b8555e Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Sun, 5 Jul 2015 19:13:04 +0000 Subject: [PATCH] CPPXT-104 - Add exception handling to integer conversions --- odbc-store/odbc-store.cpp | 10 ++++++++-- shibsp/impl/StorageServiceSessionCache.cpp | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/odbc-store/odbc-store.cpp b/odbc-store/odbc-store.cpp index 48bbe8e..f751271 100644 --- a/odbc-store/odbc-store.cpp +++ b/odbc-store/odbc-store.cpp @@ -332,8 +332,14 @@ ODBCStorageService::ODBCStorageService(const DOMElement* e) : m_log(Category::ge e = XMLHelper::getNextSiblingElement(e, RetryOnError); while (e) { if (e->hasChildNodes()) { - m_retries.push_back(XMLString::parseInt(e->getTextContent())); - m_log.info("will retry operations when native ODBC error (%ld) is returned", m_retries.back()); + try { + int code = XMLString::parseInt(e->getTextContent()); + m_retries.push_back(code); + m_log.info("will retry operations when native ODBC error (%d) is returned", code); + } + catch (XMLException&) { + m_log.error("skipping non-numeric ODBC retry code"); + } } e = XMLHelper::getNextSiblingElement(e, RetryOnError); } diff --git a/shibsp/impl/StorageServiceSessionCache.cpp b/shibsp/impl/StorageServiceSessionCache.cpp index f9fb5de..6132654 100644 --- a/shibsp/impl/StorageServiceSessionCache.cpp +++ b/shibsp/impl/StorageServiceSessionCache.cpp @@ -1860,10 +1860,16 @@ void* SSCache::cleanup_fn(void* p) // Load our configuration details... static const XMLCh cleanupInterval[] = UNICODE_LITERAL_15(c,l,e,a,n,u,p,I,n,t,e,r,v,a,l); - const XMLCh* tag=pcache->m_root ? pcache->m_root->getAttributeNS(nullptr, cleanupInterval) : nullptr; + const XMLCh* tag = pcache->m_root ? pcache->m_root->getAttributeNS(nullptr, cleanupInterval) : nullptr; int rerun_timer = 900; if (tag && *tag) { - rerun_timer = XMLString::parseInt(tag); + try { + rerun_timer = XMLString::parseInt(tag); + } + catch (XMLException&) { + pcache->m_log.error("cleanupInterval setting was not a numeric value"); + rerun_timer = 0; + } if (rerun_timer <= 0) rerun_timer = 900; } -- 2.1.4