sizeof(inHeader)));
boost::asio::read(sock, boost::asio::buffer(inBuf, inBufSize));
} catch (boost::system::system_error &e) {
- std::cerr << "Failed to communicate with simulator daemon:"
+ std::cerr << "Failed to communicate with simulator daemon: "
<< e.what() << std::endl;
return 1;
}
printUsage();
return 1;
}
- if (strcmp(argv[1], "debugport") == 0) {
- DebugPortHandler handler{};
- handler.handle(argc - 1, argv + 1);
- } else {
- printUsage();
- return 1;
+ try {
+ if (strcmp(argv[1], "debugport") == 0) {
+ DebugPortHandler handler{};
+ handler.handle(argc - 1, argv + 1);
+ } else {
+ printUsage();
+ return 1;
+ }
+ } catch (boost::system::system_error &e) {
+ std::cerr << "Internal error: " << e.what() << std::endl;
+ } catch (std::exception &e) {
+ std::cerr << "Internal error: " << e.what() << std::endl;
+ } catch (...) {
+ std::cerr << "Internal error" << std::endl;
}
}
TEEC_UUID uuid;
if (!m_opts.count("uuid"))
throw boost::program_options::required_option("uuid");
- ret = uuidStringToUuid(m_opts["uuid"].as<std::string>(), uuid);
+
+ try {
+ ret = uuidStringToUuid(m_opts["uuid"].as<std::string>(), uuid);
+ } catch(boost::bad_any_cast &e) {
+ /* This is thrown for missing and wrong-type values. It should
+ * be covered by notify and above m_opts.count check, but let's
+ * catch this pro forma
+ */
+ throw boost::program_options::error("Invalid UUID format");
+ }
if (ret)
throw boost::program_options::error(
"Invalid UUID format, expected x{8}-x{4}-x{4}-x{4}-x{12}");
int32_t DebugPortHandler::getPortArgument()
{
+ int32_t port;
if (!m_opts.count("port"))
throw boost::program_options::required_option("port");
- int32_t port = m_opts["port"].as<int32_t>();
+
+ try {
+ port = m_opts["port"].as<int32_t>();
+ } catch(boost::bad_any_cast &e) {
+ /* This is thrown for missing and wrong-type values. It should
+ * be covered by notify and above m_opts.count check, but let's
+ * catch this pro forma
+ */
+ throw boost::program_options::error("Invalid port number");
+ }
if (port < 0)
throw boost::program_options::error(
"Port number cannot be negative!");