diff options
author | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2020-03-31 14:51:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 14:51:22 +0100 |
commit | b994e86e359fd095f82feabbf38fb18a5d10e0ae (patch) | |
tree | 18e94ea5328c8804c549dd8c7cd2298161286083 | |
parent | Fix use of async/await in media code (#7184) (diff) | |
download | synapse-b994e86e359fd095f82feabbf38fb18a5d10e0ae.tar.xz |
Only setdefault for signatures if device has key_json (#7177)
-rw-r--r-- | changelog.d/7177.bugfix | 1 | ||||
-rw-r--r-- | synapse/storage/data_stores/main/devices.py | 24 |
2 files changed, 15 insertions, 10 deletions
diff --git a/changelog.d/7177.bugfix b/changelog.d/7177.bugfix new file mode 100644 index 0000000000..329a96cb0b --- /dev/null +++ b/changelog.d/7177.bugfix @@ -0,0 +1 @@ +Fix a bug which could cause outbound federation traffic to stop working if a client uploaded an incorrect e2e device signature. \ No newline at end of file diff --git a/synapse/storage/data_stores/main/devices.py b/synapse/storage/data_stores/main/devices.py index 3140e1b722..20995e1b78 100644 --- a/synapse/storage/data_stores/main/devices.py +++ b/synapse/storage/data_stores/main/devices.py @@ -286,14 +286,16 @@ class DeviceWorkerStore(SQLBaseStore): key_json = device.get("key_json", None) if key_json: result["keys"] = db_to_json(key_json) + + if "signatures" in device: + for sig_user_id, sigs in device["signatures"].items(): + result["keys"].setdefault("signatures", {}).setdefault( + sig_user_id, {} + ).update(sigs) + device_display_name = device.get("device_display_name", None) if device_display_name: result["device_display_name"] = device_display_name - if "signatures" in device: - for sig_user_id, sigs in device["signatures"].items(): - result["keys"].setdefault("signatures", {}).setdefault( - sig_user_id, {} - ).update(sigs) else: result["deleted"] = True @@ -494,14 +496,16 @@ class DeviceWorkerStore(SQLBaseStore): key_json = device.get("key_json", None) if key_json: result["keys"] = db_to_json(key_json) + + if "signatures" in device: + for sig_user_id, sigs in device["signatures"].items(): + result["keys"].setdefault("signatures", {}).setdefault( + sig_user_id, {} + ).update(sigs) + device_display_name = device.get("device_display_name", None) if device_display_name: result["device_display_name"] = device_display_name - if "signatures" in device: - for sig_user_id, sigs in device["signatures"].items(): - result["keys"].setdefault("signatures", {}).setdefault( - sig_user_id, {} - ).update(sigs) results.append(result) |