Skip to content

Commit ef57091

Browse files
authored
[MGPG-116] Up max key file size to 64K (#85)
Allow 64K files as well, as this may be "ring" (collection of keys) as well. --- https://issues.apache.org/jira/browse/MGPG-116
1 parent 944be4e commit ef57091

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/org/apache/maven/plugins/gpg/BcSigner.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@ public byte[] loadKeyFingerprint(RepositorySystemSession session) {
122122

123123
public final class GpgConfLoader implements Loader {
124124
/**
125-
* Maximum key size, see <a href="https://wiki.gnupg.org/LargeKeys">Large Keys</a>.
125+
* Maximum file size allowed to load (as we load it into heap).
126+
* <p>
127+
* This barrier exists to prevent us to load big/huge files, if this code is pointed at one
128+
* (by mistake or by malicious intent).
129+
*
130+
* @see <a href="https://wiki.gnupg.org/LargeKeys">Large Keys</a>
126131
*/
127-
private static final long MAX_SIZE = 16 * 1024 + 1L;
132+
private static final long MAX_SIZE = 64 * 1024 + 1L;
128133

129134
@Override
130135
public byte[] loadKeyRingMaterial(RepositorySystemSession session) throws IOException {
@@ -138,7 +143,7 @@ public byte[] loadKeyRingMaterial(RepositorySystemSession session) throws IOExce
138143
if (Files.size(keyPath) < MAX_SIZE) {
139144
return Files.readAllBytes(keyPath);
140145
} else {
141-
throw new IOException("Refusing to load key " + keyPath + "; is larger than 16KB");
146+
throw new IOException("Refusing to load file " + keyPath + "; is larger than 64KB");
142147
}
143148
}
144149
return null;

0 commit comments

Comments
 (0)