Skip to content

Commit

Permalink
fix(topicdata): protection against tombstone message and headers
Browse files Browse the repository at this point in the history
close #1210
  • Loading branch information
tchiotludo committed Oct 18, 2022
1 parent 4e253ac commit fea745d
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ public byte[] convertValueToWireFormat(ConsumerRecord<byte[], byte[]> record, Sc
if (schemaRegistryType == SchemaRegistryType.TIBCO) {
magicByte = (byte) 0x80;
}
Iterator<Header> contentTypeIter = record.headers().headers("contentType").iterator();
Iterator<Header> contentTypeIter = record.headers().headers("contentType").iterator();
byte[] value = record.value();
if (contentTypeIter.hasNext() &&
if (
value != null &&
contentTypeIter.hasNext() &&
value.length > 0 &&
ByteBuffer.wrap(value).get() != magicByte) {
ByteBuffer.wrap(value).get() != magicByte
) {
String headerValue = new String(contentTypeIter.next().value());
Matcher matcher = AVRO_CONTENT_TYPE_PATTERN.matcher(headerValue);
if (matcher.matches()) {
Expand Down

0 comments on commit fea745d

Please sign in to comment.