1.1 --- a/CpEpEngine.cpp Mon Dec 02 17:23:05 2019 +0100
1.2 +++ b/CpEpEngine.cpp Thu Dec 05 12:17:32 2019 +0100
1.3 @@ -1607,11 +1607,11 @@
1.4 wstring _pc = pc;
1.5
1.6 auto products = pEp::GateKeeper::gatekeeper()->registered_products();
1.7 - for (auto p = products.begin(); p != products.end(); ++p) {
1.8 - if (_pc == p->first) {
1.9 - result = pEp::GateKeeper::gatekeeper()->update_product(*p);
1.10 + for (auto& p : products) {
1.11 + if (_pc == p.second) {
1.12 + result = pEp::GateKeeper::gatekeeper()->try_update(&p);
1.13 break;
1.14 - }
1.15 + }
1.16 }
1.17 }
1.18 catch (bad_alloc&) {
2.1 --- a/GateKeeper.cpp Mon Dec 02 17:23:05 2019 +0100
2.2 +++ b/GateKeeper.cpp Thu Dec 05 12:17:32 2019 +0100
2.3 @@ -182,7 +182,7 @@
2.4
2.5 if (now > next) {
2.6 next = now + GateKeeper::cycle;
2.7 - keep_updated();
2.8 + try_update(NULL);
2.9 }
2.10
2.11 Sleep(waiting);
2.12 @@ -574,8 +574,10 @@
2.13 return result;
2.14 }
2.15
2.16 - void GateKeeper::keep_updated()
2.17 + bool GateKeeper::try_update(product *p)
2.18 {
2.19 + bool result = false;
2.20 +
2.21 NTSTATUS status = BCryptOpenAlgorithmProvider(&hAES, BCRYPT_AES_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
2.22 assert(status == 0);
2.23 if (status)
2.24 @@ -593,6 +595,16 @@
2.25 if (!internet)
2.26 goto closing;
2.27
2.28 + if (p)
2.29 + {
2.30 + try {
2.31 + result = update_product(*p);
2.32 + }
2.33 + catch (exception&) {
2.34 + result = false;
2.35 + }
2.36 + }
2.37 + else
2.38 {
2.39 product_list products = registered_products();
2.40 DWORD context = 0;
2.41 @@ -617,6 +629,8 @@
2.42 internet = NULL;
2.43 hAES = NULL;
2.44 hRSA = NULL;
2.45 +
2.46 + return result;
2.47 }
2.48
2.49 GateKeeper *GateKeeper::the_gatekeeper = nullptr;
3.1 --- a/GateKeeper.h Mon Dec 02 17:23:05 2019 +0100
3.2 +++ b/GateKeeper.h Thu Dec 05 12:17:32 2019 +0100
3.3 @@ -36,6 +36,7 @@
3.4 void keep();
3.5 product_list registered_products();
3.6 bool update_product(product p, DWORD context = 0);
3.7 + bool try_update(product *p);
3.8
3.9 static GateKeeper *gatekeeper() { return the_gatekeeper; }
3.10
3.11 @@ -57,7 +58,6 @@
3.12 BCRYPT_KEY_HANDLE delivery_key();
3.13 string wrapped_delivery_key(BCRYPT_KEY_HANDLE hDeliveryKey);
3.14
3.15 - void keep_updated();
3.16 static tstring get_lockFile();
3.17 static GateKeeper *the_gatekeeper;
3.18