Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Add range check for variables #30

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luckyfunky
Copy link

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

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

Signed-off-by: Lukas Funke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant