]> source.dussan.org Git - gitblit.git/commitdiff
authority: Fix null pointer crash for deleted users 1435/head
authorFlorian Zschocke <f.zschocke+git@gmail.com>
Mon, 31 Oct 2022 23:50:14 +0000 (00:50 +0100)
committerFlorian Zschocke <f.zschocke+git@gmail.com>
Mon, 31 Oct 2022 23:50:14 +0000 (00:50 +0100)
When a user had a certificate, i.e. an entry in the Gitblit Authority
database, but the user was deleted from the Gitblit database, then the
Authority application crashes upon loading. This patch prevents the
crash. The deleted user is no longer shown in the Authority. But the
database entry still is kept. This should be improved to show deleted
users and give the possibility to delete them from the Authority's
database.

This fixes #1359

releases.moxie
src/main/java/com/gitblit/authority/GitblitAuthority.java

index 41ad66428a5a3c6bae3ac789d505bcd9b94817f6..35e4cce438d83730c81683efa7f8f0229613118e 100644 (file)
@@ -11,7 +11,8 @@ r34: {
     html: ~
     text: ~
     security: ~
-    fixes: ~
+    fixes:
+      - Fix crash in Gitblit Authority when users were deleted from Gitblit but still had entries (certificates) in the Authority.
     changes:
       - Minimum Java required increased to Java 8
     additions: ~
index 15c23a79c8d7abf8af2cd7655eae3139c51b3072..34931bb558be2a4b04eeed37bcf7cbd6b6462083 100644 (file)
@@ -299,7 +299,11 @@ public class GitblitAuthority extends JFrame implements X509Log {
                                        List<UserCertificateModel> list = UserCertificateConfig.KEY.parse(config).list;\r
                                        for (UserCertificateModel ucm : list) {\r
                                                ucm.user = userService.getUserModel(ucm.user.username);\r
-                                               map.put(ucm.user.username, ucm);\r
+                                               // Users may have been deleted, but are still present in authority.conf.\r
+                                               // TODO: Currently this only keeps the app from crashing. It should provide means to show obsolete user entries and delete them.\r
+                                               if (ucm.user != null) {\r
+                                                       map.put(ucm.user.username, ucm);\r
+                                               }\r
                                        }\r
                                } catch (IOException e) {\r
                                        e.printStackTrace();\r