类:com.yuqi.protocol.utils.IOUtils
方法:writeLengthEncodedInteger , writeInteger
问题:
writeLengthEncodedInteger方法里的这2个分支的条件
else if (s < 2 << 16) {
IOUtils.writeByte((byte) MYSQL_TYPE_BLOB, byteBuf);
IOUtils.writeInteger(s, byteBuf, 2);
} else if (s < 2 << 24) {
IOUtils.writeByte((byte) MYSQL_TYPE_VAR_STRING, byteBuf);
IOUtils.writeInteger(s, byteBuf, 3);
}
与writeInteger方法里的校验条件不匹配,数据范围不能完全覆盖,传入后会报错过大
if (length == 3 && (s > (1 << 23) || s < -(1 << 24))) {
throw new RuntimeException("s is granter than 2^23 or less then -2^23");
}
if (length == 2 && (s > Short.MAX_VALUE || s < Short.MIN_VALUE)) {
throw new RuntimeException("Number exceed short value: " + s);
}
2 << 16 = 131072
但是进入writeInteger后,超过Short.MAX_VALUE就会报错
类:com.yuqi.protocol.utils.IOUtils
方法:writeLengthEncodedInteger , writeInteger
问题:
writeLengthEncodedInteger方法里的这2个分支的条件
与writeInteger方法里的校验条件不匹配,数据范围不能完全覆盖,传入后会报错过大
2 << 16 = 131072
但是进入writeInteger后,超过Short.MAX_VALUE就会报错