You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2012/03/28 20:33:10 UTC

svn commit: r1306527 - in /incubator/celix/trunk/framework/private/src: service_registration.c service_tracker.c

Author: pnoltes
Date: Wed Mar 28 18:33:10 2012
New Revision: 1306527

URL: http://svn.apache.org/viewvc?rev=1306527&view=rev
Log:
CELIX-30, CELIX-31, CELIX-32: Removed memory leaks and fixed buffer overflow bug.

Modified:
    incubator/celix/trunk/framework/private/src/service_registration.c
    incubator/celix/trunk/framework/private/src/service_tracker.c

Modified: incubator/celix/trunk/framework/private/src/service_registration.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registration.c?rev=1306527&r1=1306526&r2=1306527&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registration.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registration.c Wed Mar 28 18:33:10 2012
@@ -72,7 +72,7 @@ celix_status_t serviceRegistration_creat
     *registration = (SERVICE_REGISTRATION) apr_palloc(pool, sizeof(**registration));
     (*registration)->isServiceFactory = isFactory;
     (*registration)->registry = registry;
-    (*registration)->className = serviceName;
+    (*registration)->className = apr_pstrdup(pool,serviceName);
     (*registration)->bundle = bundle;
     (*registration)->references = NULL;
     arrayList_create(pool, &(*registration)->references);

Modified: incubator/celix/trunk/framework/private/src/service_tracker.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_tracker.c?rev=1306527&r1=1306526&r2=1306527&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Wed Mar 28 18:33:10 2012
@@ -61,15 +61,10 @@ celix_status_t serviceTracker_create(apr
 	} else {
 		if (status == CELIX_SUCCESS) {
 			int len = strlen(service) + strlen(OBJECTCLASS) + 4;
-			char *filter = apr_palloc(pool, sizeof(char) * len);
+			char *filter = apr_pstrcat(pool, "(", OBJECTCLASS, "=", service, ")", NULL);
 			if (filter == NULL) {
 				status = CELIX_ENOMEM;
 			} else {
-				strcpy(filter, "(");
-				strcat(filter, OBJECTCLASS);
-				strcat(filter, "=");
-				strcat(filter, service);
-				strcat(filter, ")\0");
 				serviceTracker_createWithFilter(pool, context, filter, customizer, tracker);
 			}
 		}
@@ -89,7 +84,7 @@ celix_status_t serviceTracker_createWith
 		apr_pool_pre_cleanup_register(pool, *tracker, serviceTracker_destroy);
 
 		(*tracker)->context = context;
-		(*tracker)->filter = filter;
+		(*tracker)->filter = apr_pstrdup(pool,filter);
 
 		(*tracker)->pool = pool;
 		(*tracker)->tracker = *tracker;