From: Krzysztof Jackiewicz Date: Mon, 25 Jan 2021 08:07:44 +0000 (+0100) Subject: Catch exceptions before returning to cynara X-Git-Tag: submit/tizen/20210203.135344~6^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F96%2F252596%2F2;p=platform%2Fcore%2Fsecurity%2Fkey-manager.git Catch exceptions before returning to cynara Callbacks registered in cynara may throw. Let's not propagate exceptions to cynara. Change-Id: Idc3bec6208495d0bfdb4d41c3ea0451352c9715b --- diff --git a/src/manager/main/cynara.cpp b/src/manager/main/cynara.cpp index c25031f..0a314e6 100644 --- a/src/manager/main/cynara.cpp +++ b/src/manager/main/cynara.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2015 - 2021 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -139,7 +139,14 @@ void Cynara::ChangeStatusCallback( cynara_async_status status, void *ptr) { - static_cast(ptr)->ChangeStatus(oldFd, newFd, status); + try { + static_cast(ptr)->ChangeStatus(oldFd, newFd, status); + } catch (const std::exception& e) { + LogError("Cynara::ChangeStatus failed: " << e.what()); + } catch (...) { + LogError("Cynara::ChangeStatus failed with unknown exception"); + } + } void Cynara::ProcessResponseCallback( @@ -148,7 +155,13 @@ void Cynara::ProcessResponseCallback( int response, void *ptr) { - static_cast(ptr)->ProcessResponse(checkId, cause, response); + try { + static_cast(ptr)->ProcessResponse(checkId, cause, response); + } catch (const std::exception& e) { + LogError("Cynara::ProcessResponse failed: " << e.what()); + } catch (...) { + LogError("Cynara::ProcessResponse failed with unknown exception"); + } } bool Cynara::GetUserFromSocket(int socket, std::string &user)