Function bodies 3,594 total
InvalidContentTypeException method · java · L1200-L1202 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public InvalidContentTypeException(String message) {
super(message);
}InvalidContentTypeException method · java · L1204-L1206 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public InvalidContentTypeException(String msg, Throwable cause) {
super(msg, cause);
}IOFileUploadException class · java · L1212-L1247 (36 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public static class IOFileUploadException extends FileUploadException {
/**
* The exceptions UID, for serializing an instance.
*/
private static final long serialVersionUID = 1749796615868477269L;
/**
* The exceptions cause; we overwrite the parent
* classes field, which is available since Java
* 1.4 only.
*/
private final IOException cause;
/**
* Creates a new instance with the given cause.
*
* @param pMsg The detail message.
* @param pException The exceptions cause.
*/
public IOFileUploadException(String pMsg, IOException pException) {
super(pMsg);
cause = pException;
}
/**
* Returns the exceptions cause.
*
* @return The exceptions cause, if any, or null.
*/
@Override
public Throwable getCause() {
return cause;
}
}IOFileUploadException method · java · L1232-L1235 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public IOFileUploadException(String pMsg, IOException pException) {
super(pMsg);
cause = pException;
}getCause method · java · L1243-L1245 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public Throwable getCause() {
return cause;
}SizeException class · java · L1253-L1303 (51 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
protected abstract static class SizeException extends FileUploadException {
/**
* Serial version UID, being used, if serialized.
*/
private static final long serialVersionUID = -8776225574705254126L;
/**
* The actual size of the request.
*/
private final long actual;
/**
* The maximum permitted size of the request.
*/
private final long permitted;
/**
* Creates a new instance.
*
* @param message The detail message.
* @param actual The actual number of bytes in the request.
* @param permitted The requests size limit, in bytes.
*/
protected SizeException(String message, long actual, long permitted) {
super(message);
this.actual = actual;
this.permitted = permitted;
}
/**
* Retrieves the actual size of the request.
*
* @return The acSizeException method · java · L1277-L1281 (5 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
protected SizeException(String message, long actual, long permitted) {
super(message);
this.actual = actual;
this.permitted = permitted;
}Repobility · open methodology · https://repobility.com/research/
getActualSize method · java · L1289-L1291 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public long getActualSize() {
return actual;
}getPermittedSize method · java · L1299-L1301 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public long getPermittedSize() {
return permitted;
}UnknownSizeException class · java · L1314-L1340 (27 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public static class UnknownSizeException
extends FileUploadException {
/**
* The exceptions UID, for serializing an instance.
*/
private static final long serialVersionUID = 7062279004812015273L;
/**
* Constructs a <code>UnknownSizeException</code> with no
* detail message.
*/
public UnknownSizeException() {
super();
}
/**
* Constructs an <code>UnknownSizeException</code> with
* the specified detail message.
*
* @param message The detail message.
*/
public UnknownSizeException(String message) {
super(message);
}
}UnknownSizeException method · java · L1326-L1328 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public UnknownSizeException() {
super();
}UnknownSizeException method · java · L1336-L1338 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public UnknownSizeException(String message) {
super(message);
}SizeLimitExceededException class · java · L1345-L1385 (41 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public static class SizeLimitExceededException
extends SizeException {
/**
* The exceptions UID, for serializing an instance.
*/
private static final long serialVersionUID = -2474893167098052828L;
/**
* @deprecated 1.2 Replaced by
* {@link #SizeLimitExceededException(String, long, long)}
*/
@Deprecated
public SizeLimitExceededException() {
this(null, 0, 0);
}
/**
* @deprecated 1.2 Replaced by
* {@link #SizeLimitExceededException(String, long, long)}
* @param message The exceptions detail message.
*/
@Deprecated
public SizeLimitExceededException(String message) {
this(message, 0, 0);
}
/**
* Constructs a <code>SizeExceededException</code> with
* the specified detail message, and actual and permitted sizes.
*
* @param message The detail messSizeLimitExceededException method · java · L1358-L1360 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public SizeLimitExceededException() {
this(null, 0, 0);
}SizeLimitExceededException method · java · L1368-L1370 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public SizeLimitExceededException(String message) {
this(message, 0, 0);
}Same scanner, your repo: https://repobility.com — Repobility
SizeLimitExceededException method · java · L1380-L1383 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public SizeLimitExceededException(String message, long actual,
long permitted) {
super(message, actual, permitted);
}FileSizeLimitExceededException class · java · L1390-L1462 (73 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public static class FileSizeLimitExceededException
extends SizeException {
/**
* The exceptions UID, for serializing an instance.
*/
private static final long serialVersionUID = 8150776562029630058L;
/**
* File name of the item, which caused the exception.
*/
private String fileName;
/**
* Field name of the item, which caused the exception.
*/
private String fieldName;
/**
* Constructs a <code>SizeExceededException</code> with
* the specified detail message, and actual and permitted sizes.
*
* @param message The detail message.
* @param actual The actual request size.
* @param permitted The maximum permitted request size.
*/
public FileSizeLimitExceededException(String message, long actual,
long permitted) {
super(message, actual, permitted);
}
FileSizeLimitExceededException method · java · L1416-L1419 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public FileSizeLimitExceededException(String message, long actual,
long permitted) {
super(message, actual, permitted);
}getFileName method · java · L1427-L1429 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public String getFileName() {
return fileName;
}setFileName method · java · L1437-L1439 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public void setFileName(String pFileName) {
fileName = pFileName;
}getFieldName method · java · L1447-L1449 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public String getFieldName() {
return fieldName;
}setFieldName method · java · L1458-L1460 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public void setFieldName(String pFieldName) {
fieldName = pFieldName;
}getProgressListener method · java · L1469-L1471 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public ProgressListener getProgressListener() {
return listener;
}Repobility — same analyzer, your code, free for public repos · /scan/
setProgressListener method · java · L1478-L1480 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/FileUploadBase.java
public void setProgressListener(ProgressListener pListener) {
listener = pListener;
}ProgressNotifier class · java · L92-L156 (65 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public static class ProgressNotifier {
/**
* The listener to invoke.
*/
private final ProgressListener listener;
/**
* Number of expected bytes, if known, or -1.
*/
private final long contentLength;
/**
* Number of bytes, which have been read so far.
*/
private long bytesRead;
/**
* Number of items, which have been read so far.
*/
private int items;
/**
* Creates a new instance with the given listener
* and content length.
*
* @param pListener The listener to invoke.
* @param pContentLength The expected content length.
*/
ProgressNotifier(ProgressListener pListener, long pContentLength) {
listener = pListener;
contentLength = pContentLength;
}
/**
* Called to indicate that bytes have been read.
*
* @param pBProgressNotifier method · java · L121-L124 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
ProgressNotifier(ProgressListener pListener, long pContentLength) {
listener = pListener;
contentLength = pContentLength;
}noteBytesRead method · java · L131-L137 (7 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
void noteBytesRead(int pBytes) {
/* Indicates, that the given number of bytes have been read from
* the input stream.
*/
bytesRead += pBytes;
notifyListener();
}noteItem method · java · L142-L145 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
void noteItem() {
++items;
notifyListener();
}notifyListener method · java · L150-L154 (5 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
private void notifyListener() {
if (listener != null) {
listener.update(bytesRead, contentLength, items);
}
}MultipartStream method · java · L275-L277 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public MultipartStream() {
this(null, null, null);
}MultipartStream method · java · L297-L299 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public MultipartStream(InputStream input, byte[] boundary, int bufSize) {
this(input, boundary, bufSize, null);
}All rows above produced by Repobility · https://repobility.com
MultipartStream method · java · L318-L344 (27 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public MultipartStream(InputStream input,
byte[] boundary,
int bufSize,
ProgressNotifier pNotifier) {
this.input = input;
this.bufSize = bufSize;
this.buffer = new byte[bufSize];
this.notifier = pNotifier;
// We prepend CR/LF to the boundary to chop trailing CR/LF from
// body-data tokens.
this.boundaryLength = boundary.length + BOUNDARY_PREFIX.length;
if (bufSize < this.boundaryLength + 1) {
throw new IllegalArgumentException(
"The buffer size specified for the MultipartStream is too small");
}
this.boundary = new byte[this.boundaryLength];
this.keepRegion = this.boundary.length;
System.arraycopy(BOUNDARY_PREFIX, 0, this.boundary, 0,
BOUNDARY_PREFIX.length);
System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length,
boundary.length);
head = 0;
tail = 0MultipartStream method · java · L357-L361 (5 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
MultipartStream(InputStream input,
byte[] boundary,
ProgressNotifier pNotifier) {
this(input, boundary, DEFAULT_BUFSIZE, pNotifier);
}MultipartStream method · java · L374-L377 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public MultipartStream(InputStream input,
byte[] boundary) {
this(input, boundary, DEFAULT_BUFSIZE, null);
}getHeaderEncoding method · java · L388-L390 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public String getHeaderEncoding() {
return headerEncoding;
}setHeaderEncoding method · java · L399-L401 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public void setHeaderEncoding(String encoding) {
headerEncoding = encoding;
}readByte method · java · L411-L426 (16 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public byte readByte() throws IOException {
// Buffer depleted ?
if (head == tail) {
head = 0;
// Refill.
tail = input.read(buffer, head, bufSize);
if (tail == -1) {
// No more data available.
throw new IOException("No more data is available");
}
if (notifier != null) {
notifier.noteBytesRead(tail);
}
}
return buffer[head++];
}readBoundary method · java · L439-L473 (35 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public boolean readBoundary()
throws FileUploadIOException, MalformedStreamException {
byte[] marker = new byte[2];
boolean nextChunk = false;
head += boundaryLength;
try {
marker[0] = readByte();
if (marker[0] == LF) {
// Work around IE5 Mac bug with input type=image.
// Because the boundary delimiter, not including the trailing
// CRLF, must not appear within any file (RFC 2046, section
// 5.1.1), we know the missing CR is due to a buggy browser
// rather than a file containing something similar to a
// boundary.
return true;
}
marker[1] = readByte();
if (arrayequals(marker, STREAM_TERMINATOR, 2)) {
nextChunk = false;
} else if (arrayequals(marker, FIELD_SEPARATOR, 2)) {
nextChunk = true;
} else {
setBoundary method · java · L494-L502 (9 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public void setBoundary(byte[] boundary)
throws IllegalBoundaryException {
if (boundary.length != boundaryLength - BOUNDARY_PREFIX.length) {
throw new IllegalBoundaryException(
"The length of a boundary token can not be changed");
}
System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length,
boundary.length);
}Repobility · open methodology · https://repobility.com/research/
readHeaders method · java · L520-L562 (43 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public String readHeaders() throws FileUploadIOException, MalformedStreamException {
int i = 0;
byte b;
// to support multi-byte characters
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int size = 0;
while (i < HEADER_SEPARATOR.length) {
try {
b = readByte();
} catch (FileUploadIOException e) {
// wraps a SizeException, re-throw as it will be unwrapped later
throw e;
} catch (IOException e) {
throw new MalformedStreamException("Stream ended unexpectedly");
}
if (++size > HEADER_PART_SIZE_MAX) {
throw new MalformedStreamException(
format("Header section has more than %s bytes (maybe it is not properly terminated)",
Integer.valueOf(HEADER_PART_SIZE_MAX)));
}
if (b == HEADER_SEPARATOR[i]) {
i++;readBodyData method · java · L583-L587 (5 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public int readBodyData(OutputStream output)
throws MalformedStreamException, IOException {
final InputStream istream = newInputStream();
return (int) Streams.copy(istream, output, false);
}newInputStream method · java · L593-L595 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
ItemInputStream newInputStream() {
return new ItemInputStream();
}discardBodyData method · java · L609-L611 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public int discardBodyData() throws MalformedStreamException, IOException {
return readBodyData(null);
}skipPreamble method · java · L621-L641 (21 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public boolean skipPreamble() throws IOException {
// First delimiter may be not preceeded with a CRLF.
System.arraycopy(boundary, 2, boundary, 0, boundary.length - 2);
boundaryLength = boundary.length - 2;
try {
// Discard all data up to the delimiter.
discardBodyData();
// Read boundary - if succeeded, the stream contains an
// encapsulation.
return readBoundary();
} catch (MalformedStreamException e) {
return false;
} finally {
// Restore delimiter.
System.arraycopy(boundary, 0, boundary, 2, boundary.length - 2);
boundaryLength = boundary.length;
boundary[0] = CR;
boundary[1] = LF;
}
}arrayequals method · java · L654-L663 (10 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public static boolean arrayequals(byte[] a,
byte[] b,
int count) {
for (int i = 0; i < count; i++) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}findByte method · java · L675-L684 (10 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
protected int findByte(byte value,
int pos) {
for (int i = pos; i < tail; i++) {
if (buffer[i] == value) {
return i;
}
}
return -1;
}findSeparator method · java · L694-L715 (22 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
protected int findSeparator() {
int first;
int match = 0;
int maxpos = tail - boundaryLength;
for (first = head;
(first <= maxpos) && (match != boundaryLength);
first++) {
first = findByte(boundary[0], first);
if (first == -1 || (first > maxpos)) {
return -1;
}
for (match = 1; match < boundaryLength; match++) {
if (buffer[first + match] != boundary[match]) {
break;
}
}
}
if (match == boundaryLength) {
return first - 1;
}
return -1;
}Same scanner, your repo: https://repobility.com — Repobility
MalformedStreamException class · java · L721-L746 (26 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public static class MalformedStreamException extends IOException {
/**
* The UID to use when serializing this instance.
*/
private static final long serialVersionUID = 6466926458059796677L;
/**
* Constructs a <code>MalformedStreamException</code> with no
* detail message.
*/
public MalformedStreamException() {
super();
}
/**
* Constructs an <code>MalformedStreamException</code> with
* the specified detail message.
*
* @param message The detail message.
*/
public MalformedStreamException(String message) {
super(message);
}
}MalformedStreamException method · java · L732-L734 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public MalformedStreamException() {
super();
}MalformedStreamException method · java · L742-L744 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/fixed/MultipartStream.java
public MalformedStreamException(String message) {
super(message);
}