Skip to content

Commit

Permalink
Fix buffer underrun when re-using pooled buffers #934
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Mar 15, 2019
1 parent 8e21d2e commit ee53b43
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/io/lettuce/core/codec/CipherCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,22 +303,24 @@ static KeyDescriptor from(ByteBuffer bytes) {
throw new IllegalArgumentException("Cannot extract KeyDescriptor. Malformed message header.");
}

int startPosition = bytes.position();

for (int i = 0; i < bytes.remaining(); i++) {
if (bytes.get(bytes.position() + i) == '$') {
end = bytes.position() + i;
end = (bytes.position() - startPosition) + i;
break;
}

if (bytes.get(bytes.position() + i) == '+') {
version = bytes.position() + i;
version = (bytes.position() - startPosition) + i;
}
}

if (end == -1 || version == -1) {
throw new IllegalArgumentException("Cannot extract KeyDescriptor");
}

byte[] name = new byte[version - 1];
byte[] name = new byte[version];
bytes.get(name);
bytes.get();

Expand Down

0 comments on commit ee53b43

Please sign in to comment.