kwenzh commented on PR #3732:
URL: https://github.com/apache/avro/pull/3732#issuecomment-4608596384
> > 公关 #3732 包含 pr #3635, 并删除函数 `avro_max_read`, 添加一些单元测试,应该说明更改的想法来自 #3635
>
> 我不确定你最后一点是什么意思。我在自己使用 avro
时偶然发现了这个问题。我查看了此事是否存在问题。看到您的问题但对解决方案不满意,因此决定添加我自己的 2 美分 🙂。
>
> 需要明确的是,我们的实现是不同的。甚至你可以争论的部分也更相似, `AVRO_READ_OR_FREE` 宏,不是相同的实现。 #3635
实现接受一个额外的参数,即调整大小后所需的内存长度。嗯,我想说所需的大小是 0,因此得名, `AVRO_READ_OR_FREE`.
在您的实现中,您将此参数设置为 `*len +1`. 不确定为什么,但也许这也导致一些测试失败?
ok,
1. i see it, `avro_free` do not need length param, thank you a lot
```
* The ptr parameter will be the location of any existing memory
* buffer. The osize parameter will be the size of this existing
* buffer. If ptr is NULL, then osize will be 0. The nsize parameter
* will be the size of the new buffer, or 0 if the new buffer should be
* freed.
```
2. The purpose of adding the function `avro_max_read` is to prevent
mismatched schemas and data from resulting in abnormally large lengths,
although this only happens in a minority of cases, we did encounter it.error
logs: `Cannot allocate buffer for bytes value`, i have check log, that was a so
big number mem alloc , the big number is 18446744073709551569, this is a ip v4
addres, but is mistake use to alloc memory . because this length come from
function `read_long` , some times wrong match schema and data, it will casue
read_long
https://github.com/kwenzh/avro/blob/main/lang/c/src/encoding_binary.c#L29
wrong return length.
The above is my personal research; my only concern is that the problem has
not been completely fixed.
@RyanSkraba @fabiocfabini
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]