From 91313a2e75b264601984c9c3ead68f9b75e3e478 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Tue, 23 Mar 2021 18:02:22 -0400 Subject: [PATCH] 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 This closes #4929. --- .../main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java b/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java index 0c6c575273..ee962b8ade 100644 --- a/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java +++ b/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/NaiveSearchRingBuffer.java @@ -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];