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:
Mark Payne 2021-03-23 18:02:22 -04:00 committed by Pierre Villard
parent 74ea3840ac
commit 91313a2e75
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
1 changed files with 2 additions and 2 deletions

View File

@ -50,7 +50,7 @@ public class NaiveSearchRingBuffer {
private final byte[] lookingFor;
private final int[] buffer;
private int insertionPointer = 0;
private int bufferSize = 0;
private long bufferSize = 0;
public NaiveSearchRingBuffer(final byte[] lookingFor) {
this.lookingFor = lookingFor;
@ -63,7 +63,7 @@ public class NaiveSearchRingBuffer {
* sequence for which we are looking
*/
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];
for (int i = 0; i < contentLength; i++) {
final byte nextByte = (byte) buffer[(insertionPointer + i) % lookingFor.length];