Skip to content
Permalink
Browse files
Merge pull request #413 from xuzhenbao/fix_RSA_use_after_free
Fix rsa use after free
  • Loading branch information
pnoltes committed Apr 12, 2022
2 parents 878791a + fb280b7 commit c941e1d870bc51fe873949f9a2b0ae8d35c35aaa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
@@ -234,12 +234,13 @@ celix_status_t bundleActivator_stop(void * userData, celix_bundle_context_t *con
serviceRegistration_unregister(activator->hook);
free(activator->hookService);


topologyManager_closeImports(activator->manager);
serviceRegistration_unregister(activator->endpointListenerService);
free(activator->endpointListener);

serviceRegistration_unregister(activator->scopeReg);

topologyManager_closeImports(activator->manager);

return status;
}
@@ -62,6 +62,7 @@ struct topology_manager {
celix_thread_mutex_t importedServicesLock;
celix_thread_mutexattr_t importedServicesLockAttr;
hash_map_pt importedServices;
bool closed;

scope_pt scope;

@@ -95,6 +96,7 @@ celix_status_t topologyManager_create(celix_bundle_context_t *context, celix_log
celixThreadMutexAttr_create(&(*manager)->importedServicesLockAttr);
celixThreadMutexAttr_settype(&(*manager)->importedServicesLockAttr, CELIX_THREAD_MUTEX_RECURSIVE);
celixThreadMutex_create(&(*manager)->importedServicesLock, &(*manager)->importedServicesLockAttr);
(*manager)->closed = false;

celixThreadMutex_create(&(*manager)->exportedServicesLock, NULL);
celixThreadMutex_create(&(*manager)->listenerListLock, NULL);
@@ -157,7 +159,10 @@ celix_status_t topologyManager_closeImports(topology_manager_pt manager) {

status = celixThreadMutex_lock(&manager->importedServicesLock);

manager->closed = true;

hash_map_iterator_pt iter = hashMapIterator_create(manager->importedServices);

while (hashMapIterator_hasNext(iter)) {
hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
endpoint_description_t *ep = hashMapEntry_getKey(entry);
@@ -479,6 +484,13 @@ celix_status_t topologyManager_addImportedService(void *handle, endpoint_descrip

if (celixThreadMutex_lock(&manager->importedServicesLock) == CELIX_SUCCESS) {

// We should not try to add imported services to a closed listener.
if (manager->closed) {
celixThreadMutex_unlock(&manager->importedServicesLock);
celix_logHelper_log(manager->loghelper, CELIX_LOG_LEVEL_INFO,"TOPOLOGY_MANAGER: Endpointer listener will close, Ignore imported service (%s; %s).", endpoint->service, endpoint->id);
return CELIX_SUCCESS;
}

hash_map_pt imports = hashMap_create(NULL, NULL, NULL, NULL);
hashMap_put(manager->importedServices, endpoint, imports);

0 comments on commit c941e1d

Please sign in to comment.