From c3edf42be2b4f0310676bca64e6763ba89347075 Mon Sep 17 00:00:00 2001
From: furun <furun@arcor.de>
Date: Sat, 25 Jul 2009 14:01:52 +0200
Subject: [PATCH] make blowfish library binary safe by adding a protection char
 before trimming FS#1713

Ignore-this: a3921b5eabb463ec0ba78623acfdedb8

darcs-hash:20090725120152-c0bf4-75f73dc36c914623a093f0dab48649c7d9c51fa7.gz
---
 inc/blowfish.php | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/inc/blowfish.php b/inc/blowfish.php
index b81991b25..42e3a589a 100644
--- a/inc/blowfish.php
+++ b/inc/blowfish.php
@@ -478,17 +478,18 @@ class Horde_Cipher_blowfish
  *
  * @author  lem9
  */
-function PMA_blowfish_encrypt($data, $secret) 
+function PMA_blowfish_encrypt($data, $secret)
 {
     $pma_cipher = new Horde_Cipher_blowfish;
     $encrypt = '';
-    
+
+    $data .= '_'; // triming fixed for DokuWiki FS#1690 FS#1713
     $mod = strlen($data) % 8;
-    
+
     if ($mod > 0) {
         $data .= str_repeat("\0", 8 - $mod);
     }
-    
+
     foreach (str_split($data, 8) as $chunk) {
         $encrypt .= $pma_cipher->encryptBlock($chunk, $secret);
     }
@@ -512,11 +513,9 @@ function PMA_blowfish_decrypt($encdata, $secret)
     $pma_cipher = new Horde_Cipher_blowfish;
     $decrypt = '';
     $data = base64_decode($encdata);
-    
+
     foreach (str_split($data, 8) as $chunk) {
         $decrypt .= $pma_cipher->decryptBlock($chunk, $secret);
     }
-    return trim($decrypt,"\0"); // triming fixed for DokuWiki FS#1690
+    return substr(rtrim($decrypt, "\0"), 0, -1); // triming fixed for DokuWiki FS#1690 FS#1713
 }
-
-?>
-- 
GitLab