[Sumover-dev] [svn commit] r4054 - common/trunk/src

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Mon Jun 4 11:18:14 BST 2007


Author: piers
Date: Mon Jun  4 11:18:14 2007
New Revision: 4054

Modified:
   common/trunk/src/base64.c
   common/trunk/src/mbus_config.c

Log:
Modified base64decode not to generate abort() in response to error - as it is a bit too harsh - It returns -1 which is handled by mbus_config which results in no encryption used if there is an error with the key instead of aborting - It's preferable to gracefully handle errors rather than abort() too much. Also the bse64 code is now used by vic where errors may occur and it preferable to handle them higher up in the app.


Modified: common/trunk/src/base64.c
==============================================================================
--- common/trunk/src/base64.c	(original)
+++ common/trunk/src/base64.c	Mon Jun  4 11:18:14 2007
@@ -107,8 +107,7 @@
 	int		i = 0, j = 0, pad;
 	unsigned char	c[4];
 
-	assert(output_length >= (input_length * 3 / 4));
-	assert((input_length % 4) == 0);
+	if (!(output_length >= (input_length * 3 / 4)) || !((input_length % 4) == 0)) return -1;
 	while ((i + 3) < input_length) {
 		pad  = 0;
 		c[0] = char64(input[i  ]); pad += (c[0] == 0xff);

Modified: common/trunk/src/mbus_config.c
==============================================================================
--- common/trunk/src/mbus_config.c	(original)
+++ common/trunk/src/mbus_config.c	Mon Jun  4 11:18:14 2007
@@ -404,8 +404,12 @@
                                 assert(key->key!=NULL);
 				key->key_len = strlen(key->key);
 				tmp = (char *) xmalloc(key->key_len);
-				key->key_len = base64decode((unsigned char *)key->key, key->key_len, (unsigned char *)tmp, key->key_len);
 				key->key = tmp;
+				if ((key->key_len = base64decode((unsigned char *)key->key, key->key_len, (unsigned char *)tmp, key->key_len))==-1) {
+				  debug_msg("Error in base64decode  of key from file - using NO encyption\n");
+				  key->key     = NULL;
+				  key->key_len = 0;
+				}
 			} else {
 				key->key     = NULL;
 				key->key_len = 0;



More information about the Sumover-dev mailing list