Commit 20bfdaa6 authored by Larry Sachs's avatar Larry Sachs Committed by Rick Bell

Add try/catch for stoi() and stoul() calls

A try/catch block is necessary to avoid throwing all the way back
into mpm code where it cannot be handled, causing the bridge to
become unresponsive.

Change-Id: I4031d8f8a652530404f3763d316db9bf54106023
Signed-off-by: Larry Sachs's avatarLarry Sachs <larry.j.sachs@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21349Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
Reviewed-by: default avatarRick Bell <richard.s.bell@intel.com>
parent 8545975d
......@@ -343,12 +343,24 @@ OCEntityHandlerResult UpnpGenericService::processPutRequest(OCEntityHandlerReque
else if (UPNP_TYPE_INT == type)
{
g_value_init(gValue, G_TYPE_INT);
g_value_set_int(gValue, stoi(value));
int intValue = 0;
try {
intValue = stoi(value);
} catch (const invalid_argument& ia) {
ERROR_PRINT("Failed to convert " << value << " to int");
}
g_value_set_int(gValue, intValue);
}
else if (UPNP_TYPE_UI4 == type)
{
g_value_init(gValue, G_TYPE_UINT);
g_value_set_uint(gValue, stoi(value));
unsigned int uintValue = 0;
try {
uintValue = stoul(value);
} catch (const invalid_argument& ia) {
ERROR_PRINT("Failed to convert " << value << " to uint");
}
g_value_set_uint(gValue, uintValue);
}
else {
ERROR_PRINT("No GType known for upnp type " << type);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment