You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/04/20 17:57:08 UTC
(commons-codec) 05/08: Base32 constructor fails-fast with a NullPointerException if the custom alphabet array is null
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git
commit d2215d5dec3031f819c3bb514587d92a6aec8eff
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Apr 20 13:46:13 2024 -0400
Base32 constructor fails-fast with a NullPointerException if the custom
alphabet array is null
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/commons/codec/binary/Base32.java | 3 +++
2 files changed, 4 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 01ee6076..c1e7f5e6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -49,6 +49,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Optimize memory allocation in PhoneticEngine.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">BCodec and QCodec encode() methods throw UnsupportedCharsetException instead of EncoderException.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Set Javadoc link to latest Java API LTS version.</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Base32 constructor fails-fast with a NullPointerException if the custom alphabet array is null.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base32 constructor makes a defensive copy of the line separator array.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base64 constructor makes a defensive copy of the line separator array.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base64 constructor makes a defensive copy of a custom alphabet array.</action>
diff --git a/src/main/java/org/apache/commons/codec/binary/Base32.java b/src/main/java/org/apache/commons/codec/binary/Base32.java
index ebbb57e3..ad39da40 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base32.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base32.java
@@ -17,6 +17,8 @@
package org.apache.commons.codec.binary;
+import java.util.Objects;
+
import org.apache.commons.codec.CodecPolicy;
/**
@@ -353,6 +355,7 @@ public class Base32 extends BaseNCodec {
*/
private Base32(final int lineLength, final byte[] lineSeparator, final byte[] encodeTable, final byte padding, final CodecPolicy decodingPolicy) {
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, toLength(lineSeparator), padding, decodingPolicy);
+ Objects.requireNonNull(encodeTable, "encodeTable");
this.encodeTable = encodeTable;
this.decodeTable = encodeTable == HEX_ENCODE_TABLE ? HEX_DECODE_TABLE : DECODE_TABLE;
if (lineLength > 0) {