mirror of https://github.com/google/oss-fuzz.git
54 lines
1.8 KiB
Java
54 lines
1.8 KiB
Java
// Copyright 2022 Google LLC
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
|
|
import com.code_intelligence.jazzer.api.FuzzerSecurityIssueHigh;
|
|
|
|
import java.lang.StringBuilder;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.charset.Charset;
|
|
import java.io.IOException;
|
|
import java.util.Arrays;
|
|
import java.io.UnsupportedEncodingException;
|
|
import org.apache.tomcat.util.buf.UEncoder;
|
|
import org.apache.tomcat.util.buf.UEncoder.SafeCharsSet;
|
|
import org.apache.tomcat.util.buf.UDecoder;
|
|
import org.apache.tomcat.util.buf.CharChunk;
|
|
import org.apache.catalina.util.URLEncoder;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
public class DecodeFuzzer {
|
|
static String [] encodings = {
|
|
"US-ASCII",
|
|
"ISO-8859-1",
|
|
"UTF-8",
|
|
"UTF-16BE",
|
|
"UTF-16LE",
|
|
"UTF-16"
|
|
};
|
|
|
|
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
|
|
int num = data.consumeInt(0, encodings.length - 1);
|
|
String enc = encodings[num];
|
|
String str = data.consumeRemainingAsString();
|
|
|
|
try {
|
|
String decodedData = UDecoder.URLDecode(str, Charset.forName(enc));
|
|
} catch (IllegalArgumentException e) {
|
|
}
|
|
}
|
|
}
|