Index: /Evidence/DColl.cc
===================================================================
--- /Evidence/DColl.cc	(revision 198)
+++ /Evidence/DColl.cc	(revision 199)
@@ -221,5 +221,5 @@
 	char *Token = strtok(Info->getString(), "+-!@");	
 	while (Token != NULL) {
-	  if (*Info->getString()=='-' || *Info->getString()=='!') ; // RemoveService(string(Token)+"/SERVICE_LIST");	  
+	  if (*Info->getString()=='-' || *Info->getString()=='!') RemoveService(string(Token)+"/SERVICE_LIST");	  
 	  else AddService(string(Token)+"/SERVICE_LIST");
 	  Token = strtok(NULL, "|"); // Skip server IP address
@@ -239,5 +239,5 @@
       if (strstr(Type, "|CMD")==NULL && strstr(Type, "|RPC")==NULL) {
 	    // Add or remove service
-	    if (*Info->getString()=='-' || *Info->getString()=='!') ; // RemoveService(Name);
+	    if (*Info->getString()=='-' || *Info->getString()=='!') RemoveService(Name);
 		else AddService(Name);
 	  }
@@ -350,5 +350,5 @@
   // ====== Part D: Handle history service ===
   //
-  
+
   if (Info->getSize() == 0) return;
 
@@ -468,8 +468,7 @@
 	if (Name == List[i].DataItem->getName()) return;
   }
-  
+
+  // Set minimum required change by comparing to regular expressions
   struct Item New;
-
-  // Set minimum required change by comparing to regular expressions
   New.MinAbsChange = 0;
   New.HistSize = 0;
@@ -505,5 +504,5 @@
 	}
   }
-  
+
   // Subscribe to service
   New.DataItem = new DimStampedInfo(Name.c_str(), NO_LINK, this);
Index: /Evidence/Evidence.cc
===================================================================
--- /Evidence/Evidence.cc	(revision 198)
+++ /Evidence/Evidence.cc	(revision 199)
@@ -240,9 +240,23 @@
   char *Text;
 
+  // Safety check
+  if (Item->getSize() < 1) return NULL;
+  
   // Structure: print hex representation (3 characters per byte)  
   if (strlen(Item->getFormat()) != 1) {
-    if ((Text = (char *) malloc(3*Item->getSize()+1)) != NULL) {
-	  for (int i=0; i<Item->getSize(); i++) sprintf(Text+3*i, "%02x", *((char *) Item->getData() + i)); 
-	}
+    int Size = 3*Item->getSize()+1, N;
+    if ((Text = (char *) malloc(Size)) == NULL) return NULL;
+	
+	char *CurrPos = Text;
+	for (int i=0; i<Item->getSize(); i++) {
+	  N = snprintf(CurrPos, Size, "%02x ", *((char *) Item->getData() + i));
+	  if (N<0 || N>=Size) {
+	    free(Text);
+		if (asprintf(&Text, "Structure length %d bytes, buffer overflow in ToString()", Item->getSize()) == -1) return NULL;
+		else return Text;
+	  }
+	  Size -= N;
+	  CurrPos += N;
+	} 
 	return Text;
   }
