Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
399ad9e
8277227: Better identification of OIDs
Feb 17, 2022
89d03b6
8277672: Better invocation handler handling
Feb 17, 2022
9a303ae
8277488: Add expiry exception for Digicert (geotrustglobalca) expirin…
gnu-andrew Mar 24, 2022
703cd7c
Added tag jdk8u332-b06 for changeset 6d5c4e11830c
gnu-andrew Mar 29, 2022
c3f39d0
8278008: Improve Santuario processing
Mar 29, 2022
0417c4b
8272261: Improve JFR recording file processing
olivergillespie Feb 4, 2022
c957789
8269938: Enhance XML processing passes redux
martinuy Apr 15, 2022
22ae2b4
8270504: Better Xpath expression handling
Apr 15, 2022
d5e4c82
8272255: Completely handle MIDI files
alvdavi Mar 30, 2022
d4a2cb2
8272594: Better record of recordings
martinuy Apr 15, 2022
b44052f
8274221: More definite BER encodings
alvdavi Apr 15, 2022
09520f3
8275151: Improved Object Identification
Feb 17, 2022
d72d289
8278356: Improve file creation
martinuy Apr 15, 2022
c09086e
8282397: createTempFile method of java.io.File is failing when called…
martinuy Apr 15, 2022
43ae78b
8278449: Improve keychain support
Apr 15, 2022
3ee4e62
8278805: Enhance BMP image loading
Apr 15, 2022
718c8a1
8278972: Improve URL supports
Mar 11, 2022
28bdf44
8282300: Throws NamingException instead of InvalidNameException after…
Apr 15, 2022
1feff78
8281388: Change wrapping of EncryptedPrivateKeyInfo
martinuy Apr 15, 2022
6a6f2c2
8284548: Invalid XPath expression causes StringIndexOutOfBoundsException
RealCLanger Apr 15, 2022
f1a7de1
Added tag jdk8u332-b07 for changeset 6d526dbc3432
gnu-andrew Apr 15, 2022
d0b8929
8284920: Incorrect Token type causes XPath expression to return empty…
AntonKozlov Apr 16, 2022
c7a735d
Added tag jdk8u332-b08 for changeset 95b31159fdfd
gnu-andrew Apr 16, 2022
3d2fe9b
8284936: Fix Java 7 bootstrap breakage due to use of Arrays.stream
gnu-andrew Apr 18, 2022
cc541e9
Added tag jdk8u332-b09 for changeset 37aca7715d13
gnu-andrew Apr 18, 2022
f7174b4
Merge jdk8u:master
gnu-andrew Apr 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .hgtags
Original file line number Diff line number Diff line change
Expand Up @@ -1029,3 +1029,7 @@ b81aa0cb626746f790f4b6fdcc71d84d00eff136 jdk8u332-b01
7376b980d6b085d5d9061d212f3ad69d239718e6 jdk8u332-b03
f58fc9077d2274b2832bc00ff16d112fe99d9ace jdk8u332-b04
2a92df021686242bb55ecd324b5dee00c45a0a8e jdk8u332-b05
6d5c4e11830c154190021d6ae134c5f4162ff7cc jdk8u332-b06
6d526dbc3432fd9f2db19bdcb2f6b5b8799d88f0 jdk8u332-b07
95b31159fdfd496e521e119aba9ef54acf6b272e jdk8u332-b08
37aca7715d13acfdc931aab7dbcdd41f9fd4b042 jdk8u332-b09
67 changes: 64 additions & 3 deletions jaxp/src/com/sun/java_cup/internal/runtime/lr_parser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,6 +26,8 @@

package com.sun.java_cup.internal.runtime;

import com.sun.org.apache.xalan.internal.xsltc.compiler.sym;
import java.util.Arrays;
import java.util.Stack;

/** This class implements a skeleton table driven LR parser. In general,
Expand Down Expand Up @@ -134,9 +136,19 @@
* @see com.sun.java_cup.internal.runtime.Symbol
* @see com.sun.java_cup.internal.runtime.virtual_parse_stack
* @author Frank Flannery
*
* @LastModified: Jan 2022
*/

public abstract class lr_parser {
public static final int ID_GROUP = 1;
public static final int ID_OPERATOR = 2;
public static final int ID_TOTAL_OPERATOR = 3;

private boolean isLiteral = false;
private int grpCount = 0;
private int opCount = 0;
private int totalOpCount = 0;

/*-----------------------------------------------------------*/
/*--- Constructor(s) ----------------------------------------*/
Expand Down Expand Up @@ -355,8 +367,34 @@ public void user_init() throws java.lang.Exception { }
* the "scan with" clause. Do not recycle objects; every call to
* scan() should return a fresh object.
*/
public Symbol scan() throws java.lang.Exception {
return getScanner().next_token();
public Symbol scan() throws Exception {
Symbol s = getScanner().next_token();

if (s.sym == sym.LPAREN) {
if (!isLiteral) {
grpCount++;
}
opCount++; // function
isLiteral = false;
} else if (contains(sym.OPERATORS, s.sym)) {
opCount++;
isLiteral = false;
}

if (s.sym == sym.Literal || s.sym == sym.QNAME) {
isLiteral = true;
}

return s;
}

private boolean contains(final int[] arr, final int key) {
for (int i = 0 ; i < arr.length ; ++i) {
if (arr[i] == key) {
return true;
}
}
return false;
}

/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
Expand Down Expand Up @@ -552,6 +590,9 @@ public Symbol parse() throws java.lang.Exception

/* do user initialization */
user_init();
isLiteral = false;
grpCount = 0;
opCount = 0;

/* get the first token */
cur_token = scan();
Expand Down Expand Up @@ -630,9 +671,29 @@ else if (act == 0)
}
}
}

totalOpCount += opCount;
return lhs_sym;
}

/**
* Returns the count of operators in XPath expressions.
*
* @param id the ID of the count
* @return the count associated with the ID
*/
public int getCount(int id) {
switch (id) {
case ID_GROUP:
return grpCount;
case ID_OPERATOR:
return opCount;
case ID_TOTAL_OPERATOR:
return totalOpCount;
}
return 0;
}

/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

/** Write a debugging message to System.err for the debugging version
Expand Down
15 changes: 15 additions & 0 deletions jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,21 @@ public final class XalanConstants {
*/
public static final String JDK_EXTENSION_CLASSLOADER = "jdk.xml.transform.extensionClassLoader";

/**
* JDK XPath Expression group limit
*/
public static final String XPATH_GROUP_LIMIT = "jdk.xml.xpathExprGrpLimit";

/**
* JDK XPath Expression operators limit
*/
public static final String XPATH_OP_LIMIT = "jdk.xml.xpathExprOpLimit";

/**
* JDK XSL XPath limit or Total Number of Operators Permitted in an XSL Stylesheet
*/
public static final String XPATH_TOTALOP_LIMIT = "jdk.xml.xpathTotalOpLimit";

//legacy System Properties
public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit";
public static final String ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand All @@ -24,7 +24,7 @@
import com.sun.org.apache.xalan.internal.XalanConstants;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
import jdk.xml.internal.XMLSecurityManager;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
Expand Down Expand Up @@ -465,8 +465,10 @@ public SyntaxTreeNode parse(InputSource input) {
XMLSecurityManager securityManager =
(XMLSecurityManager) _xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
lastProperty = limit.apiProperty();
reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit));
if (limit.isSupported(XMLSecurityManager.Processor.PARSER)) {
lastProperty = limit.apiProperty();
reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit));
}
}
if (securityManager.printEntityCountInfo()) {
lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO;
Expand Down Expand Up @@ -1121,6 +1123,9 @@ private SyntaxTreeNode parseTopLevel(SyntaxTreeNode parent, String text,
expression, parent));
}
catch (Exception e) {
if (ErrorMsg.XPATH_LIMIT.equals(e.getMessage())) {
throw new RuntimeException(ErrorMsg.XPATH_LIMIT);
}
if (_xsltc.debug()) e.printStackTrace();
reportError(ERROR, new ErrorMsg(ErrorMsg.XPATH_PARSER_ERR,
expression, parent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import java.util.Stack;
import java.util.Vector;
import java.io.StringReader;
import com.sun.org.apache.xalan.internal.XalanConstants;
import jdk.xml.internal.XMLLimitAnalyzer;
import jdk.xml.internal.XMLSecurityManager;
import jdk.xml.internal.XMLSecurityManager.Limit;
import com.sun.java_cup.internal.runtime.*;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xalan.internal.xsltc.DOM;
Expand All @@ -20,9 +24,12 @@
* CUP v0.11b generated parser.
* This class was generated by CUP v0.11b on Nov 12, 2019.
*
* @LastModified: Nov 2019
* @LastModified: Jan 2022
*/
public class XPathParser extends com.sun.java_cup.internal.runtime.lr_parser {
private int grpLimit = 0;
private int opLimit = 0;
private int totalOpLimit = 0;

/** Default constructor. */
public XPathParser() {
Expand Down Expand Up @@ -929,10 +936,19 @@ public int error_sym() {
*/
public SymbolTable _symbolTable;

private XMLSecurityManager _xmlSM;
private XMLLimitAnalyzer _limitAnalyzer = null;

public XPathParser(Parser parser) {
_parser = parser;
_xsltc = parser.getXSLTC();
_symbolTable = parser.getSymbolTable();
_xmlSM = (XMLSecurityManager)_xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
_limitAnalyzer = new XMLLimitAnalyzer();
// no limits if _xmlSM is null
grpLimit = (_xmlSM != null) ? _xmlSM.getLimit(Limit.XPATH_GROUP_LIMIT) : 0;
opLimit = (_xmlSM != null) ? _xmlSM.getLimit(Limit.XPATH_OP_LIMIT) : 0;
totalOpLimit = (_xmlSM != null) ? _xmlSM.getLimit(Limit.XPATH_TOTALOP_LIMIT) : 0;
}

public int getLineNumber() {
Expand Down Expand Up @@ -1078,7 +1094,32 @@ public Symbol parse(String expression, int lineNumber) throws Exception {
try {
_expression = expression;
_lineNumber = lineNumber;
return super.parse();
Symbol s = super.parse();
int grpCount = getCount(ID_GROUP);
int opCount = getCount(ID_OPERATOR);
int totalOpCount = getCount(ID_TOTAL_OPERATOR);

String errCode = null;
Object[] params = null;
if (grpLimit > 0 && grpCount > grpLimit) {
errCode = ErrorMsg.XPATH_GROUP_LIMIT;
params = new Object[]{grpCount, grpLimit,
_xmlSM.getStateLiteral(Limit.XPATH_GROUP_LIMIT)};
} else if (opLimit > 0 && opCount > opLimit) {
errCode = ErrorMsg.XPATH_OPERATOR_LIMIT;
params = new Object[]{opCount, opLimit,
_xmlSM.getStateLiteral(Limit.XPATH_OP_LIMIT)};
} else if (totalOpLimit > 0 && totalOpCount > totalOpLimit) {
errCode = ErrorMsg.XPATH_TOTAL_OPERATOR_LIMIT;
params = new Object[]{totalOpCount, totalOpLimit,
_xmlSM.getStateLiteral(Limit.XPATH_TOTALOP_LIMIT)};
}
if (errCode != null) {
_parser.reportError(Constants.FATAL,
new ErrorMsg(errCode, lineNumber, params));
throw new RuntimeException(ErrorMsg.XPATH_LIMIT);
}
return s;
} catch (IllegalCharException e) {
ErrorMsg err = new ErrorMsg(ErrorMsg.ILLEGAL_CHAR_ERR,
lineNumber, e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand All @@ -23,7 +23,6 @@
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
import com.sun.org.apache.xalan.internal.XalanConstants;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
import com.sun.org.apache.xml.internal.dtm.DTM;
Expand All @@ -47,6 +46,7 @@
import java.util.jar.Manifest;
import javax.xml.XMLConstants;
import jdk.xml.internal.JdkXmlFeatures;
import jdk.xml.internal.XMLSecurityManager;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

Expand Down Expand Up @@ -481,7 +481,10 @@ else if (systemId != null && !systemId.equals("")) {
}
}
catch (Exception e) {
/*if (_debug)*/ e.printStackTrace();
if (_debug) e.printStackTrace();
if (ErrorMsg.XPATH_LIMIT.equals(e.getMessage())) {
return !_parser.errorsFound();
}
_parser.reportError(Constants.FATAL, new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR, e));
}
catch (Error e) {
Expand Down
10 changes: 10 additions & 0 deletions jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/sym.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package com.sun.org.apache.xalan.internal.xsltc.compiler;

import java.util.Arrays;

/** CUP generated class containing symbol constants. */
public class sym {
/* terminals */
Expand Down Expand Up @@ -63,4 +65,12 @@ public class sym {
public static final int ATTRIBUTE = 41;
public static final int GT = 19;
public static final int NODE = 31;
/*
AXES: count once at DCOLON,
these axes names are therefore not counted:
NAMESPACE, FOLLOWINGSIBLING, CHILD, DESCENDANTORSELF, DESCENDANT
, PRECEDINGSIBLING, SELF, ANCESTORORSELF, PRECEDING, ANCESTOROR, PARENT, FOLLOWING, ATTRIBUTE
*/
public static final int[] OPERATORS = {GE, SLASH, ATSIGN, LPAREN, DCOLON,
MINUS, STAR, LT, OR, DIV, PLUS, LE, VBAR, MOD, EQ, LBRACK, DOLLAR, NE, GT};
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

/**
* @author Morten Jorgensen
* @LastModified: Jan 2022
*/
public class ErrorMessages extends ListResourceBundle {

Expand Down Expand Up @@ -1011,12 +1012,22 @@ public Object[][] getContents()
"smaller templates."
},

{ErrorMsg.DESERIALIZE_TRANSLET_ERR, "When Java security is enabled, " +
"support for deserializing TemplatesImpl is disabled." +
"This can be overridden by setting the jdk.xml.enableTemplatesImplDeserialization" +
" system property to true."}

};
{ErrorMsg.DESERIALIZE_TRANSLET_ERR, "When Java security is enabled, "
+ "support for deserializing TemplatesImpl is disabled. This can be "
+ "overridden by setting the jdk.xml.enableTemplatesImplDeserialization"
+ " system property to true."},

{ErrorMsg.XPATH_GROUP_LIMIT,
"JAXP0801001: the compiler encountered an XPath expression containing "
+ "''{0}'' groups that exceeds the ''{1}'' limit set by ''{2}''."},

{ErrorMsg.XPATH_OPERATOR_LIMIT,
"JAXP0801002: the compiler encountered an XPath expression containing "
+ "''{0}'' operators that exceeds the ''{1}'' limit set by ''{2}''."},
{ErrorMsg.XPATH_TOTAL_OPERATOR_LIMIT,
"JAXP0801003: the compiler encountered XPath expressions with an accumulated "
+ "''{0}'' operators that exceeds the ''{1}'' limit set by ''{2}''."},
};

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public final class ErrorMsg {

public static final String DESERIALIZE_TRANSLET_ERR = "DESERIALIZE_TEMPLATES_ERR";

public static final String XPATH_LIMIT = "XPATH_LIMIT";
public static final String XPATH_GROUP_LIMIT = "XPATH_GROUP_LIMIT";
public static final String XPATH_OPERATOR_LIMIT = "XPATH_OPERATOR_LIMIT";
public static final String XPATH_TOTAL_OPERATOR_LIMIT = "XPATH_TOTAL_OPERATOR_LIMIT";

// All error messages are localized and are stored in resource bundles.
// This array and the following 4 strings are read from that bundle.
private static ResourceBundle _bundle;
Expand Down Expand Up @@ -208,7 +213,11 @@ public ErrorMsg(String message, int line) {
public ErrorMsg(String code, int line, Object param) {
_code = code;
_line = line;
_params = new Object[] { param };
if (param instanceof Object[]) {
_params = (Object[])param;
} else {
_params = new Object[] { param };
}
}

public ErrorMsg(String code, Object param) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase.State;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
import jdk.xml.internal.XMLSecurityManager;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager;
import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.Property;
import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
Expand Down
Loading