The existing ucv_compare() implementation utilized strcmp() to compare two ucode string values, which may lead to incorrect results for strings containing null bytes as the comparison prematurely aborts when encountering the first null.
Rework the string comparison logic to use memcmp() for comparing both ucv strings with each other in order to ensure that expressions such as "" == "\u0000" lead to the expected false result.
The existing
ucv_compare()
implementation utilizedstrcmp()
to compare two ucode string values, which may lead to incorrect results for strings containing null bytes as the comparison prematurely aborts when encountering the first null.Rework the string comparison logic to use
memcmp()
for comparing both ucv strings with each other in order to ensure that expressions such as"" == "\u0000"
lead to the expectedfalse
result.Ref: https://github.com/openwrt/luci/issues/6530