DecimalVector.setBigEndian writes oversized value before validating length
还没有人认领这个 Issue。
评估
调研方向
从 DecimalVector.setBigEndian 和 Decimal256Vector.setBigEndian 开始,然后对比 setBigEndianSafe;检查固定宽度槽位和长度验证是如何处理的。为非零槽位复现一个超大输入,并添加覆盖测试,证明相邻内存保持不变,同时无效长度仍会抛出异常。完成标准是三个入口点都会在写入之前拒绝超大值。
由索引模型根据 Issue 内容生成。
描述
DecimalVector.setBigEndian(int, byte[]) and Decimal256Vector.setBigEndian(int, byte[]) validate the input length only after copying the bytes. On a little-endian platform the method byte-swaps the value into the fixed 16/32-byte slot with a loop of unchecked MemoryUtil.putByte writes:
for (int byteIdx = 0; byteIdx < length; ++byteIdx) {
MemoryUtil.putByte(outAddress + byteIdx, value[length - 1 - byteIdx]);
}
...
throw new IllegalArgumentException("Invalid decimal value length. Valid length in [1 - 16], got " + length);
If value.length exceeds the type width, the loop writes past the slot into adjacent off-heap memory before the IllegalArgumentException is thrown. MemoryUtil.putByte does no bounds checking, so this corrupts memory in the default configuration. setBigEndianSafe(int, long, ArrowBuf, int) performs the same write with no length check at all.
Reproducer: write a value into slot 1, then call setBigEndian(0, new byte[24]) on a DecimalVector; slot 1 is left corrupted (the write spills 8 bytes into it) even though the call throws.
- 主要语言
- Java
- 星标
- 95
- 派生
- 154
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 11
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/arrow-java 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
apache/arrow-java#1261 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
apache/arrow-java#1236 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
apache/arrow-java#1230 ·
-
Type: bug
难度 2/5 1-3 小时 新手友好度 85/100
apache/arrow-java#1205 ·
-
Type: bug
难度 2/5 1-3 小时 新手友好度 68/100
apache/arrow-java#1196 · 1 条评论 ·
查看 apache/arrow-java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 1/5 1 小时以内 新手友好度 88/100
checkstyle/test-configs#263 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
1.0.0-alpha2 Type/Improvement
难度 2/5 1-3 小时 新手友好度 68/100
wso2/dpdp-accelerator#272 ·