diff options
author | Gunnar Wagenknecht <gunnar@wagenknecht.org> | 2019-04-02 13:47:07 -0700 |
---|---|---|
committer | Gunnar Wagenknecht <gunnar@wagenknecht.org> | 2019-04-03 03:11:58 -0700 |
commit | 440296873b8200fbba5f3d2a5d3f71708d75f2fc (patch) | |
tree | 8b86e925480c1da54e33d8789ca73ad1f906303b | |
parent | 27f1fb668f09bccf7c506f51f16d70d04ec8a240 (diff) | |
download | jgit-440296873b8200fbba5f3d2a5d3f71708d75f2fc.tar.gz jgit-440296873b8200fbba5f3d2a5d3f71708d75f2fc.zip |
Ignore invalid files in '.gnupg/private-keys-v1.d'
Bug: 545673
Change-Id: I4a2ee1e76f320209b3f8090264d771f1a9da566f
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java index 091667db01..c942cf403d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java @@ -85,6 +85,8 @@ import org.eclipse.jgit.errors.UnsupportedCredentialItem; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.SystemReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Locates GPG keys from either <code>~/.gnupg/private-keys-v1.d</code> or @@ -92,6 +94,9 @@ import org.eclipse.jgit.util.SystemReader; */ class BouncyCastleGpgKeyLocator { + private static final Logger log = LoggerFactory + .getLogger(BouncyCastleGpgKeyLocator.class); + private static final Path GPG_DIRECTORY = findGpgDirectory(); private static final Path USER_KEYBOX_PATH = GPG_DIRECTORY @@ -157,11 +162,14 @@ class BouncyCastleGpgKeyLocator { private PGPSecretKey attemptParseSecretKey(Path keyFile, PGPDigestCalculatorProvider calculatorProvider, PBEProtectionRemoverFactory passphraseProvider, - PGPPublicKey publicKey) throws IOException { + PGPPublicKey publicKey) { try (InputStream in = newInputStream(keyFile)) { return new SExprParser(calculatorProvider).parseSecretKey( new BufferedInputStream(in), passphraseProvider, publicKey); - } catch (PGPException | ClassCastException e) { + } catch (IOException | PGPException | ClassCastException e) { + if (log.isDebugEnabled()) + log.debug("Ignoring unreadable file '{}': {}", keyFile, //$NON-NLS-1$ + e.getMessage(), e); return null; } } |