code: protected static void sanityCheck(byte[] buf, int offset, int length) {
          if(buf == null) throw new NullPointerException("buffer is null");
          if(offset + length > buf.length)
              throw new ArrayIndexOutOfBoundsException("length (" + length + ") + offset (" + offset +
                                                         ") > buf.length (" + buf.length + ")");
      }
docs: Verifies that length doesn't exceed a buffer's length
  @param buf
  @param offset
  @param length