Skip to content

RFC: Add range check for variables

Created by: luckyfunky

This is untested with U-Boot. I'm hope to get some feedback whether such feature is desirable or even makes sense before invensting more time in it (starting the counter-part in U-Boot).

As a use-case I see general validation for variables to prevent system misconfiguration.

Here the commit message/usage information:

Add range check for variables using the ".flags" variable. Different types of ranges can be specified for strings, decimals and hex-values.

  • For string one can specify a regular expression for valid string.
  • For decimals one can specify an integer range
  • For hex values one can specify a bitmask

The range is added by the '@' character after the access flags.

Example:

Environment:

.flags=foo:sw@r"aaab+",bla:dw@100-200,blub:xw@0xffff foo=aaab bla=123 blub=0x1234

Commandline:

$ fw_setenv foo aaac libuboot_set_env failed: -1

$ fw_setenv foo aaabbbb $ fw_printenv bla=123 blub=0x1234 foo=aaabbb

Merge request reports