From 3d07ac359e54d37183f2623a8a842fc862672beb Mon Sep 17 00:00:00 2001 From: Andrey Shcheglov Date: Fri, 6 Dec 2019 19:05:33 +0300 Subject: [PATCH] IDEA-228410 Avoid the NPE when a secret key has multiple user ids attached to it GitOrigin-RevId: 6a10c3a5dc7c76bb790048ebf6638f15b88765c4 --- platform/credential-store/src/gpg/gpgUtil.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/credential-store/src/gpg/gpgUtil.kt b/platform/credential-store/src/gpg/gpgUtil.kt index 0f93dbc503d9..69f202cea381 100644 --- a/platform/credential-store/src/gpg/gpgUtil.kt +++ b/platform/credential-store/src/gpg/gpgUtil.kt @@ -34,6 +34,9 @@ internal class Pgp(private val gpgTool: GpgToolWrapper = createGpg()) { capabilities = fields.next() } + /* + * There may be multiple user identities ("uid") following a single secret key ("sec"). + */ "uid" -> { // a potential letter 'D' to indicate a disabled key // e :: Encrypt @@ -46,8 +49,6 @@ internal class Pgp(private val gpgTool: GpgToolWrapper = createGpg()) { // The value is quoted like a C string to avoid control characters (the colon is quoted =\x3a=). result.add(PgpKey(keyId!!, fields.next().replace("=\\x3a=", ":"))) } - keyId = null - capabilities = null } } }