Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
condenser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
condenser
Commits
58929438
Commit
58929438
authored
8 years ago
by
James Calfee
Browse files
Options
Downloads
Patches
Plain Diff
Add fail-safe to memo decryption in case sender does not length prefix the memo.
#202
parent
8f84aced
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shared/chain/memo.js
+1
-9
1 addition, 9 deletions
shared/chain/memo.js
with
1 addition
and
9 deletions
shared/chain/memo.js
+
1
−
9
View file @
58929438
...
@@ -33,18 +33,10 @@ export function decode(private_key, memo) {
...
@@ -33,18 +33,10 @@ export function decode(private_key, memo) {
const
mbuf
=
ByteBuffer
.
fromBinary
(
memo
.
toString
(
'
binary
'
),
ByteBuffer
.
DEFAULT_CAPACITY
,
ByteBuffer
.
LITTLE_ENDIAN
)
const
mbuf
=
ByteBuffer
.
fromBinary
(
memo
.
toString
(
'
binary
'
),
ByteBuffer
.
DEFAULT_CAPACITY
,
ByteBuffer
.
LITTLE_ENDIAN
)
try
{
try
{
mbuf
.
mark
()
mbuf
.
mark
()
// I get better luck using readVString .. but (see cache)
return
mbuf
.
readVString
()
return
mbuf
.
readVString
()
}
catch
(
e
)
{
}
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
()
mbuf
.
reset
()
const
len
=
mbuf
.
readVarint32
()
// remove the varint length prefix
// Sender did not length-prefix the memo
const
remaining
=
mbuf
.
remaining
()
if
(
len
!==
remaining
)
// warn
console
.
error
(
`Memo's length prefix
${
len
}
does not match remaining bytes
${
remaining
}
`
)
memo
=
new
Buffer
(
mbuf
.
toString
(
'
binary
'
),
'
binary
'
).
toString
(
'
utf-8
'
)
memo
=
new
Buffer
(
mbuf
.
toString
(
'
binary
'
),
'
binary
'
).
toString
(
'
utf-8
'
)
return
memo
return
memo
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment