From 41c938eede3e9ea29ef86f3c25bab8fa6a51a509 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Fri, 6 Jul 2012 13:45:38 +0200 Subject: IPC-server hardening and update - add IMPLEMENT_RANDOMIZE_STACK for ipcThread() - log / print boost interprocess exceptions - use MAX_URI_LENGTH in guiconstants.h (also used in qrcodedialog.cpp) - remove unneeded includes and ipcShutdown() from qtipcserver.cpp - fix a small mem-leak by deleting mq before re-using it - make ipcThread() and ipcThread2() static functions - add some more comments --- src/qt/bitcoin.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/qt/bitcoin.cpp') diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 55b5f74c3b..f9f5115cd0 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -126,13 +126,21 @@ int main(int argc, char *argv[]) const char *strURI = argv[i]; try { boost::interprocess::message_queue mq(boost::interprocess::open_only, BITCOINURI_QUEUE_NAME); - if(mq.try_send(strURI, strlen(strURI), 0)) + if (mq.try_send(strURI, strlen(strURI), 0)) + // if URI could be sent to the message queue exit here exit(0); else + // if URI could not be sent to the message queue do a normal Bitcoin-Qt startup break; } catch (boost::interprocess::interprocess_exception &ex) { - break; + // don't log the "file not found" exception, because that's normal for + // the first start of the first instance + if (ex.get_error_code() != boost::interprocess::not_found_error) + { + printf("main() - boost interprocess exception #%d: %s\n", ex.get_error_code(), ex.what()); + break; + } } } } @@ -278,6 +286,8 @@ int main(int argc, char *argv[]) mq.try_send(strURI, strlen(strURI), 0); } catch (boost::interprocess::interprocess_exception &ex) { + printf("main() - boost interprocess exception #%d: %s\n", ex.get_error_code(), ex.what()); + break; } } } -- cgit v1.2.3