uci: reset uci_ptr flags when merging set operations
authorJo-Philipp Wich <jo@mein.io>
Tue, 29 Oct 2019 07:28:17 +0000 (08:28 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 26 May 2020 14:16:50 +0000 (16:16 +0200)
commitabbc3020dcfb6ed7dcbcf8eaf27e17a8fc9df83c
tree689c9a8f033f478a9d28dafbf2103050317d4788
parent3aa81d0dfae167eccc26203bd0c96f3e3450f253
uci: reset uci_ptr flags when merging set operations

In some cases, e.g. when subsequently setting multiple empty option
values, uci_set() might free the section pointer of the given reused
uci_ptr structure without zeroing it, leading to a use-after-free on
processing subsequent options.

Avoid this issue by clearing the lookup pointer flags in order to
prevent uci_set() from incorrectly branching into a uci_delete()
operation leading to the freeing of the section member.

Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-October/019592.html
Reported-by: Daniel Danzberger <daniel@dd-wrt.com>
Suggested-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit bd0ed2521476c3e5b6c1a0e0bd2c386ea809d74b)
uci.c