Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Timo Ley
synapse
Commits
8b45de90
Unverified
Commit
8b45de90
authored
7 years ago
by
Richard van der Hoff
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2719 from matrix-org/rav/handle_missing_hashes
Fix 500 when joining matrix-dev
parents
c2a11944
7303ed65
Branches
Branches containing commit
Tags
v0.10.0-rc6
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/crypto/event_signing.py
+10
-3
10 additions, 3 deletions
synapse/crypto/event_signing.py
with
10 additions
and
3 deletions
synapse/crypto/event_signing.py
+
10
−
3
View file @
8b45de90
...
...
@@ -32,15 +32,22 @@ def check_event_content_hash(event, hash_algorithm=hashlib.sha256):
"""
Check whether the hash for this PDU matches the contents
"""
name
,
expected_hash
=
compute_content_hash
(
event
,
hash_algorithm
)
logger
.
debug
(
"
Expecting hash: %s
"
,
encode_base64
(
expected_hash
))
if
name
not
in
event
.
hashes
:
# some malformed events lack a 'hashes'. Protect against it being missing
# or a weird type by basically treating it the same as an unhashed event.
hashes
=
event
.
get
(
"
hashes
"
)
if
not
isinstance
(
hashes
,
dict
):
raise
SynapseError
(
400
,
"
Malformed
'
hashes
'"
,
Codes
.
UNAUTHORIZED
)
if
name
not
in
hashes
:
raise
SynapseError
(
400
,
"
Algorithm %s not in hashes %s
"
%
(
name
,
list
(
event
.
hashes
),
name
,
list
(
hashes
),
),
Codes
.
UNAUTHORIZED
,
)
message_hash_base64
=
event
.
hashes
[
name
]
message_hash_base64
=
hashes
[
name
]
try
:
message_hash_bytes
=
decode_base64
(
message_hash_base64
)
except
Exception
:
...
...
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