Function bodies 3,594 total
getHeaders method · java · L874-L876 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public FileItemHeaders getHeaders() {
return headers;
}setHeaders method · java · L883-L885 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public void setHeaders(FileItemHeaders pHeaders) {
headers = pHeaders;
}FileItemIteratorImpl method · java · L938-L999 (62 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
FileItemIteratorImpl(RequestContext ctx)
throws FileUploadException, IOException {
if (ctx == null) {
throw new NullPointerException("ctx parameter");
}
String contentType = ctx.getContentType();
if ((null == contentType)
|| (!contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART))) {
throw new InvalidContentTypeException(
format("the request doesn't contain a %s or %s stream, content type header is %s",
MULTIPART_FORM_DATA, MULTIPART_FORM_DATA, contentType));
}
InputStream input = ctx.getInputStream();
@SuppressWarnings("deprecation") // still has to be backward compatible
final int contentLengthInt = ctx.getContentLength();
final long requestSize = UploadContext.class.isAssignableFrom(ctx.getClass())
/raiseError method · java · L972-L979 (8 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
protected void raiseError(long pSizeMax, long pCount)
throws IOException {
FileUploadException ex = new SizeLimitExceededException(
format("the request was rejected because its size (%s) exceeds the configured maximum (%s)",
Long.valueOf(pCount), Long.valueOf(pSizeMax)),
pCount, pSizeMax);
throw new FileUploadIOException(ex);
}findNextItem method · java · L1007-L1073 (67 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
private boolean findNextItem() throws IOException {
if (eof) {
return false;
}
if (currentItem != null) {
currentItem.close();
currentItem = null;
}
for (;;) {
boolean nextPart;
if (skipPreamble) {
nextPart = multi.skipPreamble();
} else {
nextPart = multi.readBoundary();
}
if (!nextPart) {
if (currentFieldName == null) {
// Outer multipart terminated -> No more data
eof = true;
return false;
}
// Inner multipart terminated -> Return to parsing the outer
multi.setBoundary(boundary);
currentFieldName = null;
continue;
}
FileItemHeadersgetContentLength method · java · L1075-L1081 (7 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
private long getContentLength(FileItemHeaders pHeaders) {
try {
return Long.parseLong(pHeaders.getHeader(CONTENT_LENGTH));
} catch (Exception e) {
return -1;
}
}hasNext method · java · L1093-L1106 (14 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public boolean hasNext() throws FileUploadException, IOException {
if (eof) {
return false;
}
if (itemValid) {
return true;
}
try {
return findNextItem();
} catch (FileUploadIOException e) {
// unwrap encapsulated SizeException
throw (FileUploadException) e.getCause();
}
}Want fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
next method · java · L1119-L1125 (7 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public FileItemStream next() throws FileUploadException, IOException {
if (eof || (!itemValid && !hasNext())) {
throw new NoSuchElementException();
}
itemValid = false;
return currentItem;
}FileUploadIOException class · java · L1133-L1168 (36 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public static class FileUploadIOException extends IOException {
/**
* The exceptions UID, for serializing an instance.
*/
private static final long serialVersionUID = -7047616958165584154L;
/**
* The exceptions cause; we overwrite the parent
* classes field, which is available since Java
* 1.4 only.
*/
private final FileUploadException cause;
/**
* Creates a <code>FileUploadIOException</code> with the
* given cause.
*
* @param pCause The exceptions cause, if any, or null.
*/
public FileUploadIOException(FileUploadException pCause) {
// We're not doing super(pCause) cause of 1.3 compatibility.
cause = pCause;
}
/**
* Returns the exceptions cause.
*
* @return The exceptions cause, if any, or null.
*/
@Override
public Throwable getCause() {
FileUploadIOException method · java · L1153-L1156 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public FileUploadIOException(FileUploadException pCause) {
// We're not doing super(pCause) cause of 1.3 compatibility.
cause = pCause;
}getCause method · java · L1164-L1166 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public Throwable getCause() {
return cause;
}InvalidContentTypeException class · java · L1173-L1199 (27 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public static class InvalidContentTypeException
extends FileUploadException {
/**
* The exceptions UID, for serializing an instance.
*/
private static final long serialVersionUID = -9073026332015646668L;
/**
* Constructs a <code>InvalidContentTypeException</code> with no
* detail message.
*/
public InvalidContentTypeException() {
// Nothing to do.
}
/**
* Constructs an <code>InvalidContentTypeException</code> with
* the specified detail message.
*
* @param message The detail message.
*/
public InvalidContentTypeException(String message) {
super(message);
}
}InvalidContentTypeException method · java · L1185-L1187 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public InvalidContentTypeException() {
// Nothing to do.
}InvalidContentTypeException method · java · L1195-L1197 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public InvalidContentTypeException(String message) {
super(message);
}IOFileUploadException class · java · L1204-L1239 (36 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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;
}
}Same scanner, your repo: https://repobility.com — Repobility
IOFileUploadException method · java · L1224-L1227 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public IOFileUploadException(String pMsg, IOException pException) {
super(pMsg);
cause = pException;
}getCause method · java · L1235-L1237 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public Throwable getCause() {
return cause;
}SizeException class · java · L1245-L1295 (51 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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 · L1269-L1273 (5 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
protected SizeException(String message, long actual, long permitted) {
super(message);
this.actual = actual;
this.permitted = permitted;
}getActualSize method · java · L1281-L1283 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public long getActualSize() {
return actual;
}getPermittedSize method · java · L1291-L1293 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public long getPermittedSize() {
return permitted;
}UnknownSizeException class · java · L1306-L1332 (27 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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 · L1318-L1320 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public UnknownSizeException() {
super();
}Repobility · code-quality intelligence · https://repobility.com
UnknownSizeException method · java · L1328-L1330 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public UnknownSizeException(String message) {
super(message);
}SizeLimitExceededException class · java · L1337-L1377 (41 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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 · L1350-L1352 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public SizeLimitExceededException() {
this(null, 0, 0);
}SizeLimitExceededException method · java · L1360-L1362 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public SizeLimitExceededException(String message) {
this(message, 0, 0);
}SizeLimitExceededException method · java · L1372-L1375 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public SizeLimitExceededException(String message, long actual,
long permitted) {
super(message, actual, permitted);
}FileSizeLimitExceededException class · java · L1382-L1454 (73 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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 · L1408-L1411 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public FileSizeLimitExceededException(String message, long actual,
long permitted) {
super(message, actual, permitted);
}getFileName method · java · L1419-L1421 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public String getFileName() {
return fileName;
}Repobility · code-quality intelligence platform · https://repobility.com
setFileName method · java · L1429-L1431 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public void setFileName(String pFileName) {
fileName = pFileName;
}getFieldName method · java · L1439-L1441 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public String getFieldName() {
return fieldName;
}setFieldName method · java · L1450-L1452 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public void setFieldName(String pFieldName) {
fieldName = pFieldName;
}getProgressListener method · java · L1461-L1463 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public ProgressListener getProgressListener() {
return listener;
}setProgressListener method · java · L1470-L1472 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/FileUploadBase.java
public void setProgressListener(ProgressListener pListener) {
listener = pListener;
}ProgressNotifier class · java · L92-L156 (65 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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/vulnerable/MultipartStream.java
ProgressNotifier(ProgressListener pListener, long pContentLength) {
listener = pListener;
contentLength = pContentLength;
}noteBytesRead method · java · L131-L137 (7 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
void noteBytesRead(int pBytes) {
/* Indicates, that the given number of bytes have been read from
* the input stream.
*/
bytesRead += pBytes;
notifyListener();
}Want fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
noteItem method · java · L142-L145 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
void noteItem() {
++items;
notifyListener();
}notifyListener method · java · L150-L154 (5 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
private void notifyListener() {
if (listener != null) {
listener.update(bytesRead, contentLength, items);
}
}MultipartStream method · java · L277-L279 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
public MultipartStream() {
this(null, null, null);
}MultipartStream method · java · L301-L303 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
public MultipartStream(InputStream input, byte[] boundary, int bufSize) {
this(input, boundary, bufSize, null);
}MultipartStream method · java · L323-L344 (22 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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.boundary = new byte[boundary.length + BOUNDARY_PREFIX.length];
this.boundaryLength = boundary.length + BOUNDARY_PREFIX.length;
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 = 0;
}MultipartStream method · java · L358-L362 (5 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
MultipartStream(InputStream input,
byte[] boundary,
ProgressNotifier pNotifier) {
this(input, boundary, DEFAULT_BUFSIZE, pNotifier);
}MultipartStream method · java · L377-L380 (4 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
public MultipartStream(InputStream input,
byte[] boundary) {
this(input, boundary, DEFAULT_BUFSIZE, null);
}getHeaderEncoding method · java · L391-L393 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
public String getHeaderEncoding() {
return headerEncoding;
}Same scanner, your repo: https://repobility.com — Repobility
setHeaderEncoding method · java · L402-L404 (3 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/MultipartStream.java
public void setHeaderEncoding(String encoding) {
headerEncoding = encoding;
}readByte method · java · L414-L429 (16 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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 · L442-L476 (35 LOC)data/dim2b/scenarios/vul4j-11-cwe264/vulnerable/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 {