diff common/listutil.c @ 1395:a2574a029322

Fix Base 64 signature size calculation. If the signature byte size is not equally dividable by three the base 64 encoding needs three additional bytes. The value is now fixed to avoid such errors in the future.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 26 Jan 2015 13:17:32 +0100
parents 8d27c6d226cd
children
line wrap: on
line diff
--- a/common/listutil.c	Fri Jan 23 15:25:50 2015 +0100
+++ b/common/listutil.c	Mon Jan 26 13:17:32 2015 +0100
@@ -125,7 +125,7 @@
 #ifndef TRUSTBRIDGE_RSA_KEY_SIZE
 # error "Key size undefined"
 #endif
-  const size_t sig_b64_size = TRUSTBRIDGE_RSA_KEY_SIZE / 8 * 4 / 3;
+  const size_t sig_b64_size = TRUSTBRIDGE_RSA_B64_SIZE;
   size_t sig_size = TRUSTBRIDGE_RSA_KEY_SIZE / 8;
 
   char signature_b64[sig_b64_size + 1];
@@ -144,7 +144,7 @@
   if (p == 0 || (unsigned int)(p - (data + 2)) != sig_b64_size)
     {
       DEBUGPRINTF("Invalid data. Signature might be too long.\n");
-      DEBUGPRINTF("Should: %u is: %u\n", sig_b64_size, (unsigned int)(p - (data + 2)));
+      DEBUGPRINTF("Should: %u is: %u\n", (unsigned int) sig_b64_size, (unsigned int)(p - (data + 2)));
       return -1;
     }
   strncpy(signature_b64, data + 2, sig_b64_size);

http://wald.intevation.org/projects/trustbridge/