celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1650294 - in /celix/trunk: log_writer/log_writer_stdout/private/src/ remote_services/calculator_proxy/private/src/ remote_services/calculator_proxy2/private/src/ remote_services/remote_service_admin_http/private/src/ shell/private/src/
Date Thu, 08 Jan 2015 14:29:38 GMT
Author: abroekhuis
Date: Thu Jan  8 14:29:38 2015
New Revision: 1650294

URL: http://svn.apache.org/r1650294
Log:
CELIX-198: Updated log_command to determine message length, and use snprintf to prevent overflows.

Modified:
    celix/trunk/log_writer/log_writer_stdout/private/src/log_writer_stdout.c
    celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c
    celix/trunk/remote_services/calculator_proxy2/private/src/calculator_proxy_activator.c
    celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
    celix/trunk/shell/private/src/log_command.c

Modified: celix/trunk/log_writer/log_writer_stdout/private/src/log_writer_stdout.c
URL: http://svn.apache.org/viewvc/celix/trunk/log_writer/log_writer_stdout/private/src/log_writer_stdout.c?rev=1650294&r1=1650293&r2=1650294&view=diff
==============================================================================
--- celix/trunk/log_writer/log_writer_stdout/private/src/log_writer_stdout.c (original)
+++ celix/trunk/log_writer/log_writer_stdout/private/src/log_writer_stdout.c Thu Jan  8 14:29:38
2015
@@ -37,8 +37,6 @@
 
 celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt entry) {
 	celix_status_t status = CELIX_SUCCESS;
-    module_pt module = NULL;
-    char *sName = NULL;
 
     if (!entry) {
         status = CELIX_ILLEGAL_ARGUMENT;

Modified: celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c?rev=1650294&r1=1650293&r2=1650294&view=diff
==============================================================================
--- celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c
(original)
+++ celix/trunk/remote_services/calculator_proxy/private/src/calculator_proxy_activator.c
Thu Jan  8 14:29:38 2015
@@ -109,7 +109,6 @@ static celix_status_t calculatorProxyFac
 
 static celix_status_t calculatorProxyFactory_destroy(void *handle, void *service) {
 	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = handle;
 	calculator_service_pt calculatorService = service;
 
 	if (!calculatorService) {

Modified: celix/trunk/remote_services/calculator_proxy2/private/src/calculator_proxy_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/calculator_proxy2/private/src/calculator_proxy_activator.c?rev=1650294&r1=1650293&r2=1650294&view=diff
==============================================================================
--- celix/trunk/remote_services/calculator_proxy2/private/src/calculator_proxy_activator.c
(original)
+++ celix/trunk/remote_services/calculator_proxy2/private/src/calculator_proxy_activator.c
Thu Jan  8 14:29:38 2015
@@ -109,7 +109,6 @@ static celix_status_t calculatorProxyFac
 
 static celix_status_t calculatorProxyFactory_destroy(void *handle, void *service) {
 	celix_status_t status = CELIX_SUCCESS;
-	struct activator *activator = handle;
 	calculator_service_pt calculatorService = service;
 
 	if (!calculatorService) {

Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c?rev=1650294&r1=1650293&r2=1650294&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
Thu Jan  8 14:29:38 2015
@@ -221,7 +221,6 @@ celix_status_t remoteServiceAdmin_stop(r
     {
     	hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
 
-    	char* service = hashMapEntry_getKey(entry);
     	import_registration_factory_pt importFactory = hashMapEntry_getValue(entry);
 
         int i;

Modified: celix/trunk/shell/private/src/log_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/log_command.c?rev=1650294&r1=1650293&r2=1650294&view=diff
==============================================================================
--- celix/trunk/shell/private/src/log_command.c (original)
+++ celix/trunk/shell/private/src/log_command.c Thu Jan  8 14:29:38 2015
@@ -55,7 +55,6 @@ void logCommand_execute(command_pt comma
 
     bundleContext_getServiceReference(command->bundleContext, (char *) OSGI_LOGSERVICE_READER_SERVICE_NAME,
&readerService);
     if (readerService != NULL) {
-        char line[256];
         linked_list_pt list = NULL;
         linked_list_iterator_pt iter = NULL;
         log_reader_service_pt reader = NULL;
@@ -70,15 +69,19 @@ void logCommand_execute(command_pt comma
 			char *level = NULL;
 			char errorString[256];
 
-			strftime(time, 20, "%Y-%m-%d %H:%M:%S", localtime(&entry->time));
+			size_t timeLength = strftime(time, 20, "%Y-%m-%d %H:%M:%S", localtime(&entry->time));
 			logCommand_levelAsString(command, entry->level, &level);
 
 			if (entry->errorCode > 0) {
 				celix_strerror(entry->errorCode, errorString, 256);
-				sprintf(line, "%s - Bundle: %s - %s - %d %s\n", time, entry->bundleSymbolicName, entry->message,
entry->errorCode, errorString);
+				size_t length = timeLength + strlen(entry->bundleSymbolicName) + strlen(entry->message)
+ strlen(errorString) + 40;
+		        char line[length];
+				snprintf(line, length, "%s - Bundle: %s - %s - %d %s\n", time, entry->bundleSymbolicName,
entry->message, entry->errorCode, errorString);
 				out(line);
 			} else {
-				sprintf(line, "%s - Bundle: %s - %s\n", time, entry->bundleSymbolicName, entry->message);
+				size_t length = timeLength + strlen(entry->bundleSymbolicName) + strlen(entry->message)
+ 20;
+				char line[length];
+				snprintf(line, length, "%s - Bundle: %s - %s\n", time, entry->bundleSymbolicName,
entry->message);
 				out(line);
 			}
 		}



Mime
View raw message