jow- / ucode

JavaScript-like language with optional templating
ISC License
87 stars 24 forks source link

types: improve comparison reliability of binary strings #168

Closed jow- closed 10 months ago

jow- commented 10 months ago

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.

Ref: https://github.com/openwrt/luci/issues/6530