mirror of https://github.com/apache/nifi.git
NIFI-8360: Fixed an overflow issue where we used an integer to store the number of bytes encountered when reading data and searching for a given pattern
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #4929.
This commit is contained in:
parent
74ea3840ac
commit
91313a2e75
|
@ -50,7 +50,7 @@ public class NaiveSearchRingBuffer {
|
||||||
private final byte[] lookingFor;
|
private final byte[] lookingFor;
|
||||||
private final int[] buffer;
|
private final int[] buffer;
|
||||||
private int insertionPointer = 0;
|
private int insertionPointer = 0;
|
||||||
private int bufferSize = 0;
|
private long bufferSize = 0;
|
||||||
|
|
||||||
public NaiveSearchRingBuffer(final byte[] lookingFor) {
|
public NaiveSearchRingBuffer(final byte[] lookingFor) {
|
||||||
this.lookingFor = lookingFor;
|
this.lookingFor = lookingFor;
|
||||||
|
@ -63,7 +63,7 @@ public class NaiveSearchRingBuffer {
|
||||||
* sequence for which we are looking
|
* sequence for which we are looking
|
||||||
*/
|
*/
|
||||||
public byte[] getBufferContents() {
|
public byte[] getBufferContents() {
|
||||||
final int contentLength = Math.min(lookingFor.length, bufferSize);
|
final int contentLength = (int) Math.min(lookingFor.length, bufferSize);
|
||||||
final byte[] contents = new byte[contentLength];
|
final byte[] contents = new byte[contentLength];
|
||||||
for (int i = 0; i < contentLength; i++) {
|
for (int i = 0; i < contentLength; i++) {
|
||||||
final byte nextByte = (byte) buffer[(insertionPointer + i) % lookingFor.length];
|
final byte nextByte = (byte) buffer[(insertionPointer + i) % lookingFor.length];
|
||||||
|
|
Loading…
Reference in New Issue