Fix base64_decode() to return and check length correctly
diff --git a/ChangeLog b/ChangeLog
index 03c7e31..ded66e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -67,6 +67,8 @@
    * Use \n\t rather than semicolons for bn_mul asm, since some assemblers
      interpret semicolons as comment delimiters (found by Barry K. Nathan).
    * Disable broken Sparc64 bn_mul assembly (found by Florian Obser).
+   * Fix base64_decode() to return and check length correctly (in case of
+     tight buffers)
 
 = Version 1.2.10 released 2013-10-07
 Changes
diff --git a/library/base64.c b/library/base64.c
index 06305bb..1364713 100644
--- a/library/base64.c
+++ b/library/base64.c
@@ -162,6 +162,7 @@
         return( 0 );
 
     n = ((n * 6) + 7) >> 3;
+    n -= j;
 
     if( *dlen < n )
     {