Merge pull request #11911 from s1monw/no_utf_uuid

Don't convert possibly corrupted bytes to UTF-8
This commit is contained in:
Simon Willnauer 2015-06-29 15:00:40 +02:00
commit 2dfd6df369
1 changed files with 3 additions and 2 deletions

View File

@ -233,8 +233,9 @@ public abstract class TranslogReader implements Closeable, Comparable<TranslogRe
BytesRef ref = new BytesRef(len);
ref.length = len;
headerStream.read(ref.bytes, ref.offset, ref.length);
if (ref.utf8ToString().equals(translogUUID) == false) {
throw new TranslogCorruptedException("expected shard UUID [" + translogUUID + "] but got: [" + ref.utf8ToString() + "] this translog file belongs to a different translog");
BytesRef uuidBytes = new BytesRef(translogUUID);
if (uuidBytes.bytesEquals(ref) == false) {
throw new TranslogCorruptedException("expected shard UUID [" + uuidBytes + "] but got: [" + ref + "] this translog file belongs to a different translog");
}
return new ImmutableTranslogReader(channelReference.getGeneration(), channelReference, ref.length + CodecUtil.headerLength(TranslogWriter.TRANSLOG_CODEC) + RamUsageEstimator.NUM_BYTES_INT, checkpoint.offset, checkpoint.numOps);
default: