aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Polański <michal@polanski.me>2021-02-06 01:32:24 +0100
committerTBK <tbk@jjtc.eu>2021-02-06 20:49:15 +0000
commit1dd70e918544cc42ef292b8d7ef82a047a9cc1e7 (patch)
tree99db051d10d0b8dd0c7739fb58d85fb9f9b20cdb
parent306ce113c06494afbf65f8c2f1998849615c4003 (diff)
downloadaports-1dd70e918544cc42ef292b8d7ef82a047a9cc1e7.tar.gz
aports-1dd70e918544cc42ef292b8d7ef82a047a9cc1e7.tar.bz2
aports-1dd70e918544cc42ef292b8d7ef82a047a9cc1e7.tar.xz
testing/dendrite: fix crash in the membership updater
-rw-r--r--testing/dendrite/APKBUILD6
-rw-r--r--testing/dendrite/ccf700f5c645f3f9a0de65d2431b47684ee79901.patch37
2 files changed, 41 insertions, 2 deletions
diff --git a/testing/dendrite/APKBUILD b/testing/dendrite/APKBUILD
index 77fb13914c..5f2735ba50 100644
--- a/testing/dendrite/APKBUILD
+++ b/testing/dendrite/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=dendrite
pkgver=0.3.9
-pkgrel=0
+pkgrel=1
pkgdesc="Second-generation Matrix homeserver written in Go"
url="https://github.com/matrix-org/dendrite"
license="Apache-2.0"
@@ -15,6 +15,7 @@ install="$pkgname.pre-install"
source="https://github.com/matrix-org/dendrite/archive/v$pkgver/dendrite-v$pkgver.tar.gz
dendrite.initd
dendrite.confd
+ ccf700f5c645f3f9a0de65d2431b47684ee79901.patch
"
options="net" # Required to download Go deps
@@ -40,4 +41,5 @@ package() {
sha512sums="9a1ae30647d4ce1d59a54530af54ff2bb1bc52a166170698b6ff547b5ee0d69a192dee5d8c74ca28722d717b9843c6cff22865818de69a45c8ef84e2168db2bf dendrite-v0.3.9.tar.gz
92274e4f52eb0f35822d7f27279efd372b7959d8531ad7a247286727defc375ca4b4939ed7b82fa29061a0b3c923a6c41ac0f27f3cfd8acb9c96af72ffac333c dendrite.initd
-a6a088683a6aebc431d3eb289bd0d4dbaede698d1a5da25d6af2aad79e9cd36db02ce9173ab6904249f23b88bca5d1630258736feef7e8266e6c22220d74fa1f dendrite.confd"
+a6a088683a6aebc431d3eb289bd0d4dbaede698d1a5da25d6af2aad79e9cd36db02ce9173ab6904249f23b88bca5d1630258736feef7e8266e6c22220d74fa1f dendrite.confd
+d1821f45d6edce47b008da566832a95b3658cd6ddc5efd0f08c24b9dee1f9aa5d007cfe357ace36a6159a1bfb1e0c5bde116f5c6c221f16fbe03397b97b609b8 ccf700f5c645f3f9a0de65d2431b47684ee79901.patch"
diff --git a/testing/dendrite/ccf700f5c645f3f9a0de65d2431b47684ee79901.patch b/testing/dendrite/ccf700f5c645f3f9a0de65d2431b47684ee79901.patch
new file mode 100644
index 0000000000..0d1130a585
--- /dev/null
+++ b/testing/dendrite/ccf700f5c645f3f9a0de65d2431b47684ee79901.patch
@@ -0,0 +1,37 @@
+From ccf700f5c645f3f9a0de65d2431b47684ee79901 Mon Sep 17 00:00:00 2001
+From: Neil Alexander <neilalexander@users.noreply.github.com>
+Date: Fri, 5 Feb 2021 23:51:45 +0000
+Subject: [PATCH] Fix nil pointer exception in membership updater
+
+---
+ roomserver/internal/input/input_membership.go | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/roomserver/internal/input/input_membership.go b/roomserver/internal/input/input_membership.go
+index bc646c3c6..b3fbb5dfc 100644
+--- a/roomserver/internal/input/input_membership.go
++++ b/roomserver/internal/input/input_membership.go
+@@ -106,6 +106,23 @@ func (r *Inputer) updateMembership(
+ // immediately, unless it's a Join update (e.g. profile update).
+ return updates, nil
+ }
++
++ // In an ideal world, we shouldn't ever have "add" be nil and "remove" be
++ // set, as this implies that we're deleting a state event without replacing
++ // it (a thing that ordinarily shouldn't happen in Matrix). However, state
++ // resets are sadly a thing occasionally and we have to account for that.
++ // Beforehand there used to be a check here which stopped dead if we hit
++ // this scenario, but that meant that the membership table got out of sync
++ // after a state reset, often thinking that the user was still joined to
++ // the room even though the room state said otherwise, and this would prevent
++ // the user from being able to attempt to rejoin the room without modifying
++ // the database. So instead what we'll do is we'll just update the membership
++ // table to say that the user is "leave" and we'll use the old event to
++ // avoid nil pointer exceptions on the code path that follows.
++ if add == nil {
++ add = remove
++ newMembership = gomatrixserverlib.Leave
++ }
+
+ mu, err := updater.MembershipUpdater(targetUserNID, r.isLocalTarget(add))
+ if err != nil {