Fix CVE-2022-34169 for xalan-j2
(cherry picked from commit 803e327b8074422329308cb7b21f2e0380c5c631)
This commit is contained in:
parent
4933bbff10
commit
d1cbb2a404
85
CVE-2022-34169.patch
Normal file
85
CVE-2022-34169.patch
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
From 13bf52c8d876528a43be7cb77a1f452d29a21492 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aleksei Voitylov <avoitylov@openjdk.org>
|
||||||
|
Date: Mon, 30 May 2022 12:26:00 +0000
|
||||||
|
Subject: [PATCH] 8285407: Improve Xalan supports
|
||||||
|
|
||||||
|
Refer: https://github.com/openjdk/jdk11u/commit/13bf52c8d876528a43be7cb77a1f452d29a21492
|
||||||
|
---
|
||||||
|
.../org/apache/bcel/classfile/ConstantPool.java | 12 ++++++++++--
|
||||||
|
.../org/apache/bcel/generic/ConstantPoolGen.java | 14 ++++++++++++--
|
||||||
|
2 files changed, 22 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/apache/bcel/classfile/ConstantPool.java b/src/main/java/org/apache/bcel/classfile/ConstantPool.java
|
||||||
|
index c8bc32a..9e465c6 100644
|
||||||
|
--- a/src/main/java/org/apache/bcel/classfile/ConstantPool.java
|
||||||
|
+++ b/src/main/java/org/apache/bcel/classfile/ConstantPool.java
|
||||||
|
@@ -22,6 +22,7 @@ import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.bcel.Const;
|
||||||
|
+import org.apache.bcel.generic.ConstantPoolGen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the constant pool, i.e., a table of constants, of
|
||||||
|
@@ -218,8 +219,15 @@ public class ConstantPool implements Cloneable, Node {
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void dump( final DataOutputStream file ) throws IOException {
|
||||||
|
- file.writeShort(constant_pool.length);
|
||||||
|
- for (int i = 1; i < constant_pool.length; i++) {
|
||||||
|
+ /*
|
||||||
|
+ * Constants over the size of the constant pool shall not be written out.
|
||||||
|
+ * This is a redundant measure as the ConstantPoolGen should have already
|
||||||
|
+ * reported an error back in the situation.
|
||||||
|
+ */
|
||||||
|
+ int size = constant_pool.length < ConstantPoolGen.CONSTANT_POOL_SIZE - 1 ?
|
||||||
|
+ constant_pool.length : ConstantPoolGen.CONSTANT_POOL_SIZE - 1;
|
||||||
|
+ file.writeShort(size);
|
||||||
|
+ for (int i = 1; i < size; i++) {
|
||||||
|
if (constant_pool[i] != null) {
|
||||||
|
constant_pool[i].dump(file);
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java b/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java
|
||||||
|
index f3a766e..9c7f252 100644
|
||||||
|
--- a/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java
|
||||||
|
+++ b/src/main/java/org/apache/bcel/generic/ConstantPoolGen.java
|
||||||
|
@@ -52,6 +52,7 @@ import org.apache.bcel.classfile.ConstantUtf8;
|
||||||
|
public class ConstantPoolGen {
|
||||||
|
|
||||||
|
private static final int DEFAULT_BUFFER_SIZE = 256;
|
||||||
|
+ public static final int CONSTANT_POOL_SIZE = 65536;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated (since 6.0) will be made private; do not access directly, use getter/setter
|
||||||
|
@@ -95,7 +96,7 @@ public class ConstantPoolGen {
|
||||||
|
public ConstantPoolGen(final Constant[] cs) {
|
||||||
|
final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE);
|
||||||
|
|
||||||
|
- size = Math.max(DEFAULT_BUFFER_SIZE, cs.length + 64);
|
||||||
|
+ size = Math.min(cs.length, CONSTANT_POOL_SIZE);
|
||||||
|
constants = new Constant[size];
|
||||||
|
|
||||||
|
System.arraycopy(cs, 0, constants, 0, cs.length);
|
||||||
|
@@ -224,9 +225,18 @@ public class ConstantPoolGen {
|
||||||
|
/** Resize internal array of constants.
|
||||||
|
*/
|
||||||
|
protected void adjustSize() {
|
||||||
|
- if (index + 3 >= size) {
|
||||||
|
+ // 3 extra spaces are needed as some entries may take 3 slots
|
||||||
|
+ if (index + 3 >= CONSTANT_POOL_SIZE) {
|
||||||
|
+ throw new RuntimeException("The number of constants " + (index + 3)
|
||||||
|
+ + " is over the size of the constant pool: "
|
||||||
|
+ + (CONSTANT_POOL_SIZE - 1));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (index + 3 >= size) {
|
||||||
|
final Constant[] cs = constants;
|
||||||
|
size *= 2;
|
||||||
|
+ // the constant array shall not exceed the size of the constant pool
|
||||||
|
+ size = Math.min(size, CONSTANT_POOL_SIZE);
|
||||||
|
constants = new Constant[size];
|
||||||
|
System.arraycopy(cs, 0, constants, 0, index);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,10 +1,11 @@
|
|||||||
Name: bcel
|
Name: bcel
|
||||||
Version: 6.4.1
|
Version: 6.4.1
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: Byte Code Engineering Library
|
Summary: Byte Code Engineering Library
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: http://commons.apache.org/proper/commons-bcel/
|
URL: http://commons.apache.org/proper/commons-bcel/
|
||||||
Source0: http://archive.apache.org/dist/commons/bcel/source/bcel-%{version}-src.tar.gz
|
Source0: http://archive.apache.org/dist/commons/bcel/source/bcel-%{version}-src.tar.gz
|
||||||
|
Patch0: CVE-2022-34169.patch
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: maven-local mvn(org.apache.commons:commons-parent:pom:)
|
BuildRequires: maven-local mvn(org.apache.commons:commons-parent:pom:)
|
||||||
Obsoletes: bcel-javadoc < %{version}-%{release}
|
Obsoletes: bcel-javadoc < %{version}-%{release}
|
||||||
@ -37,6 +38,9 @@ Java class files (those ending with .class).
|
|||||||
%{_javadocdir}/%{name}
|
%{_javadocdir}/%{name}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Sep 23 2022 wangkai <wangkai385@h-partners.com> -6.4.1-2
|
||||||
|
- Fix CVE-2022-34169 for xalan-j2
|
||||||
|
|
||||||
* Wed Feb 16 2022 yaoxin <yaoxin30@huawei.com> - 6.4.1-1
|
* Wed Feb 16 2022 yaoxin <yaoxin30@huawei.com> - 6.4.1-1
|
||||||
- When bcel is upgraded to 6.5.0,other packages that depend on bcel fail to be compiled.
|
- When bcel is upgraded to 6.5.0,other packages that depend on bcel fail to be compiled.
|
||||||
- Downgrade bcel to 6.4.1.
|
- Downgrade bcel to 6.4.1.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user