cgi, file: fix crash due to field_len type mismatch with libubox#24
Conversation
danpawlik
left a comment
There was a problem hiding this comment.
Thank you for this patch. Works well with luci statistics.
|
Edit: or maybe not, seems libubox calloc_a() always expected size_t sized variable arguments after the pointer addresses and your commit to uhttpd ensures that on platforms where sizeof(size_t) != sizeof(int). One of these things where one wonders how it could possibly work before. |
In libubox commit openwrt/libubox@9b48801, the type of `alloc_len` in `calloc_a` was changed to `size_t`. Since uhttpd still defined `field_len` as returning `int`, this type mismatch caused uhttpd to crash. So change `field_len` type to `size_t` and add NULL check. Fixes: openwrt/luci#8629 Fixes: openwrt/libubox#45 Signed-off-by: Andy Chiang <AndyChiang_git@outlook.com> Link: #24 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
The AI found some more places with the same problem. Felix already fixed some and I also have PRs to OpenWrt for some: libubox itself ubus uclient mdnsd rpcd unetd procd uhttpd |
|
If AI made the type change in libubox in the first place openwrt/libubox@9b48801 , how come it didn't realize the large number of locations it broke code depending on this? It's very strange working like this... backwards. |
In libubox commit openwrt/libubox@9b48801, the type of
alloc_lenincalloc_awas changed tosize_t.Since uhttpd still defined
field_lenas returningint, this type mismatch caused uhttpd to crash. So changefield_lentype tosize_tand add NULL check.Fixes: openwrt/luci#8629
Fixes: openwrt/libubox#45