Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for CVE-2023-33201 #1837

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,59 @@ public Collection engineGetCRLs(CRLSelector selector)

return crlSet;
}
private static String[] FILTER_ESCAPE_TABLE = new String['\\' + 1];


static {

// Filter encoding table -------------------------------------

// fill with char itself
for (char c = 0; c < FILTER_ESCAPE_TABLE.length; c++) {
FILTER_ESCAPE_TABLE[c] = String.valueOf(c);
}

// escapes (RFC2254)
FILTER_ESCAPE_TABLE['*'] = "\\2a";
FILTER_ESCAPE_TABLE['('] = "\\28";
FILTER_ESCAPE_TABLE[')'] = "\\29";
FILTER_ESCAPE_TABLE['\\'] = "\\5c";
FILTER_ESCAPE_TABLE[0] = "\\00";

}

/**
* Escape a value for use in a filter.
* @param value the value to escape.
* @return a properly escaped representation of the supplied value.
*/
private String filterEncode(String value)
{
if (value == null)
{
return null;
}

// make buffer roomy
StringBuilder encodedValue = new StringBuilder(value.length() * 2);

int length = value.length();

for (int i = 0; i < length; i++) {

char c = value.charAt(i);

if (c < FILTER_ESCAPE_TABLE.length) {
encodedValue.append(FILTER_ESCAPE_TABLE[c]);
}
else {
// default: add the char
encodedValue.append(c);
}
}

return encodedValue.toString();
}

/**
* Returns a Set of byte arrays with the certificate or CRL encodings.
Expand All @@ -408,7 +461,8 @@ public Collection engineGetCRLs(CRLSelector selector)
private Set search(String attributeName, String attributeValue,
String[] attrs) throws CertStoreException
{
String filter = attributeName + "=" + attributeValue;
String filter = attributeName + "=" + filterEncode(attributeValue);
System.out.println(filter);
if (attributeName == null)
{
filter = null;
Expand Down