Fixed integer overflow in sessionimpl.cpp (#1803) (#1820)

* Fix integer overflow in sessionimpl.cpp

* Modify document of setConnectionTimeout

Add discription of exception.
This commit is contained in:
Yasuhiro Horimoto
2017-07-20 22:25:22 +09:00
committed by Aleksandar Fabijanic
parent 40324cdcc0
commit a767d55a81
2 changed files with 13 additions and 4 deletions

View File

@@ -75,6 +75,7 @@ public:
void setConnectionTimeout(std::size_t timeout);
/// Sets the session connection timeout value.
/// Throws RangeException if the timeout value is overflow.
std::size_t getConnectionTimeout();
/// Returns the session connection timeout value.

View File

@@ -222,12 +222,20 @@ bool SessionImpl::isConnected()
void SessionImpl::setConnectionTimeout(std::size_t timeout)
{
if(timeout >= 0 && (timeout <= INT_MAX/1000))
{
int tout = 1000 * timeout;
int rc = sqlite3_busy_timeout(_pDB, tout);
if (rc != 0) Utility::throwException(rc);
_timeout = tout;
}
else
{
throw RangeException
("Occurred integer overflow because of timeout value.");
}
}
void SessionImpl::setConnectionTimeout(const std::string& prop, const Poco::Any& value)