From 58929438a1a4623f1aa65f918a66104d91b4bfdb Mon Sep 17 00:00:00 2001
From: James Calfee <james@jcalfee.info>
Date: Thu, 8 Sep 2016 17:44:59 -0500
Subject: [PATCH] Add fail-safe to memo decryption in case sender does not
 length prefix the memo. #202

---
 shared/chain/memo.js | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/shared/chain/memo.js b/shared/chain/memo.js
index 72cb8abaa..f4831a01a 100644
--- a/shared/chain/memo.js
+++ b/shared/chain/memo.js
@@ -33,18 +33,10 @@ export function decode(private_key, memo) {
     const mbuf = ByteBuffer.fromBinary(memo.toString('binary'), ByteBuffer.DEFAULT_CAPACITY, ByteBuffer.LITTLE_ENDIAN)
     try {
         mbuf.mark()
-        // I get better luck using readVString .. but (see cache)
         return mbuf.readVString()
     } catch(e) {
-        // Piston's encrypted memos fail the above varibale length utf-8 conversion.
-        // The origainal code works for Piston.
-        // https://github.com/steemit/steemit.com/issues/202
         mbuf.reset()
-        const len = mbuf.readVarint32() // remove the varint length prefix
-        const remaining = mbuf.remaining()
-        if(len !== remaining) // warn
-            console.error(`Memo's length prefix ${len} does not match remaining bytes ${remaining}`)
-
+        // Sender did not length-prefix the memo
         memo = new Buffer(mbuf.toString('binary'), 'binary').toString('utf-8')
         return memo
     }
-- 
GitLab