mjsax commented on code in PR #23156:
URL: https://github.com/apache/kafka/pull/23156#discussion_r3808603403
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorMetadata.java:
##########
@@ -52,9 +53,15 @@ public static ProcessorMetadata deserialize(final byte[]
metaDataBytes) {
final ByteBuffer buffer = ByteBuffer.wrap(metaDataBytes);
final int entrySize = buffer.getInt();
+ if (entrySize < 0 || entrySize > buffer.remaining() / (Integer.BYTES +
Long.BYTES)) {
+ throw new BufferUnderflowException();
+ }
final Map<String, Long> metadata = new HashMap<>(entrySize);
for (int i = 0; i < entrySize; i++) {
final int keySize = buffer.getInt();
+ if (keySize < 0 || keySize > buffer.remaining() - Long.BYTES) {
Review Comment:
Seems the `- Long.BYTES` doesn't really make a big difference for the check.
Should we remove it to keep the code simpler?
Of course, also ok to leave as is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]