MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / checkArrayLength

Method checkArrayLength

src/HBaseRpc.java:1032–1045  ·  view source on GitHub ↗

Verifies that the given length looks like a reasonable array length. This method accepts 0 as a valid length. @param buf The buffer from which the length was read. @param length The length to validate. @throws IllegalArgumentException if the length is negative or suspiciously large.

(final ChannelBuffer buf, final long length)

Source from the content-addressed store, hash-verified

1030 * suspiciously large.
1031 */
1032 static void checkArrayLength(final ChannelBuffer buf, final long length) {
1033 // 2 checks in 1. If any of the high bits are set, we know the value is
1034 // either too large, or is negative (if the most-significant bit is set).
1035 if ((length & MAX_BYTE_ARRAY_MASK) != 0) {
1036 if (length < 0) {
1037 throw new IllegalArgumentException("Read negative byte array length: "
1038 + length + " in buf=" + buf + '=' + Bytes.pretty(buf));
1039 } else {
1040 throw new IllegalArgumentException("Read byte array length that's too"
1041 + " large: " + length + " > " + ~MAX_BYTE_ARRAY_MASK + " in buf="
1042 + buf + '=' + Bytes.pretty(buf));
1043 }
1044 }
1045 }
1046
1047 /**
1048 * Verifies that the given array looks like a reasonably big array.

Callers 13

readByteArrayMethod · 0.95
readHadoopStringMethod · 0.95
readProtobufMethod · 0.95
decodeMethod · 0.95
deserializeMethod · 0.95
parseResultMethod · 0.95
fromBufferMethod · 0.95
checkQualifierMethod · 0.95
checkValueMethod · 0.95

Calls 1

prettyMethod · 0.95

Tested by

no test coverage detected