celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [1/4] celix git commit: CELIX-249: Fixes a bug where tmp allocated char* where assigned to endpoints.
Date Wed, 06 Jul 2016 11:02:36 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 2cd57a789 -> 6f85bf3c2


CELIX-249: Fixes a bug where tmp allocated char* where assigned to endpoints.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/38f2fe48
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/38f2fe48
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/38f2fe48

Branch: refs/heads/develop
Commit: 38f2fe484bc77eac9d19e59fb6aeb2417b6aeed8
Parents: 2cd57a7
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Wed Jul 6 09:58:29 2016 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Wed Jul 6 09:58:29 2016 +0200

----------------------------------------------------------------------
 .../rsa/private/src/remote_service_admin_dfi.c  |  3 +-
 .../private/src/remote_service_admin_impl.c     | 34 +++++++++++---------
 .../private/src/remote_service_admin_impl.c     |  3 +-
 3 files changed, 23 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/38f2fe48/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
b/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
index 16134fe..48c2364 100644
--- a/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
+++ b/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
@@ -548,7 +548,7 @@ static celix_status_t remoteServiceAdmin_createEndpointDescription(remote_servic
         serviceReference_getProperty(reference, (char*) OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
         (*endpoint)->serviceId = strtoull(serviceId, NULL, 0);
         (*endpoint)->frameworkUUID = (char*) properties_get(endpointProperties, (char*)
OSGI_RSA_ENDPOINT_FRAMEWORK_UUID);
-        (*endpoint)->service = interface;
+        (*endpoint)->service = strndup(interface, 1024*10);
         (*endpoint)->properties = endpointProperties;
     }
 
@@ -596,6 +596,7 @@ celix_status_t remoteServiceAdmin_destroyEndpointDescription(endpoint_descriptio
     celix_status_t status = CELIX_SUCCESS;
 
     properties_destroy((*description)->properties);
+    free((*description)->service);
     free(*description);
 
     return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/38f2fe48/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
b/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
index 75ec5d0..f73d094 100644
--- a/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
+++ b/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
@@ -399,32 +399,33 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt
admin, c
 		return CELIX_ILLEGAL_STATE;
 	}
 
-	const char *exports = NULL;
-	const char *provided = NULL;
-	serviceReference_getProperty(reference, OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports);
-	serviceReference_getProperty(reference, OSGI_FRAMEWORK_OBJECTCLASS, &provided);
-
-	if (exports == NULL || provided == NULL) {
+	const char *exportsProp = NULL;
+	const char *providedProp = NULL;
+	serviceReference_getProperty(reference, OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exportsProp);
+	serviceReference_getProperty(reference, OSGI_FRAMEWORK_OBJECTCLASS, &providedProp);
+	
+	if (exportsProp == NULL || providedProp == NULL) {
 		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: No Services to export.");
 	} else {
+		char *exports = strndup(exportsProp, 1024*10);
+		char *provided = strndup(providedProp, 1024*10);
+
 		logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Export services (%s)", exports);
 		array_list_pt interfaces = NULL;
 		arrayList_create(&interfaces);
-		char *cmpExports = strndup(exports, 1024*10);
-		char *providedCopy = strndup(provided, 1024*10);
-		if (strcmp(utils_stringTrim(cmpExports), "*") == 0) {
+		if (strcmp(utils_stringTrim(exports), "*") == 0) {
 			char *save_ptr = NULL;
-			char *interface = strtok_r(providedCopy, ",", &save_ptr);
+			char *interface = strtok_r(provided, ",", &save_ptr);
 			while (interface != NULL) {
 				arrayList_add(interfaces, utils_stringTrim(interface));
 				interface = strtok_r(NULL, ",", &save_ptr);
 			}
 		} else {
 			char *provided_save_ptr = NULL;
-			char *pinterface = strtok_r(providedCopy, ",", &provided_save_ptr);
+			char *pinterface = strtok_r(provided, ",", &provided_save_ptr);
 			while (pinterface != NULL) {
 				char *exports_save_ptr = NULL;
-				char *einterface = strtok_r(cmpExports, ",", &exports_save_ptr);
+				char *einterface = strtok_r(exports, ",", &exports_save_ptr);
 				while (einterface != NULL) {
 					if (strcmp(einterface, pinterface) == 0) {
 						arrayList_add(interfaces, einterface);
@@ -434,8 +435,6 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt
admin, c
 				pinterface = strtok_r(NULL, ",", &provided_save_ptr);
 			}
 		}
-		free(cmpExports);
-		free(providedCopy);
 
 		if (arrayList_size(interfaces) != 0) {
 			int iter = 0;
@@ -457,8 +456,12 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt
admin, c
 
 		}
 		arrayList_destroy(interfaces);
+		free(exports);
+		free(provided);
 	}
 
+	
+
 	return status;
 }
 
@@ -598,7 +601,7 @@ celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin
 		serviceReference_getProperty(reference, (char*)OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
 		(*description)->serviceId = strtoull(serviceId, NULL, 0);
 		(*description)->frameworkUUID = (char*)properties_get(endpointProperties, OSGI_RSA_ENDPOINT_FRAMEWORK_UUID);
-		(*description)->service = interface;
+		(*description)->service = strndup(interface, 1024*10);
 		(*description)->properties = endpointProperties;
 	}
 
@@ -611,6 +614,7 @@ celix_status_t remoteServiceAdmin_destroyEndpointDescription(endpoint_descriptio
 	celix_status_t status = CELIX_SUCCESS;
 
 	properties_destroy((*description)->properties);
+	free((*description)->service);
 	free(*description);
 
 	return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/38f2fe48/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
b/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
index c760590..f090223 100644
--- a/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
+++ b/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
@@ -810,7 +810,7 @@ celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin
 			serviceReference_getProperty(reference, (char*)OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
 			(*description)->serviceId = strtoull(serviceId, NULL, 0);
 			(*description)->id = (char*)properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID);
-			(*description)->service = interface;
+			(*description)->service = strndup(interface, 1024*10);
 		}
 	}
 
@@ -821,6 +821,7 @@ celix_status_t remoteServiceAdmin_destroyEndpointDescription(endpoint_descriptio
 	celix_status_t status = CELIX_SUCCESS;
 
 	properties_destroy((*description)->properties);
+	free((*description)->service);
 	free(*description);
 
 	return status;


Mime
View raw message