[PATCH 00/10] setexpr: Correct various bugs and add tests plus string support

Simon Glass sjg at chromium.org
Sun Nov 1 22:15:34 CET 2020


This command has several bugs that were discovered in trying to get zboot
to make use of regular expression substitution:

- reads the wrong values with 'setexpr.l' or 'setexpr' on 64-bit machines
- buffer overflow of main string buffer
- buffer overflow of 'new' string buffer
- produces the wrong string in some cases when using back references

This series corrects these bugs and adds regression tests for them. It
also adds several other tests for the command and the core logic of
setexpr.

Finally, with Chrome OS boot it is necessary to read a command-line string
from memory, process it with a regex and then provide it to the zboot
command. So this series adds support for these features, as well as string
concatenation.

This series is available at u-boot-dm/sete-working


Simon Glass (10):
  test: Add some tests for setexpr
  command: Add constants for cmd_get_data_size string / error
  setexpr: Add explicit support for 32- and 64-bit ints
  test: Add some setexpr regex tests
  setexpr: Split the core logic into its own function
  setexpr: Add some tests for buffer overflow and backref
  setexpr: Correct dropping of final unmatched string
  setexpr: Correct buffer overflow bug and enable tests
  setexpr: Convert to use a struct for values
  setexpr: Add support for strings

 cmd/itest.c           |   4 +-
 cmd/mem.c             |   2 +-
 cmd/setexpr.c         | 336 ++++++++++++++++++++++++------------
 common/command.c      |   4 +-
 include/command.h     |  43 ++++-
 include/test/suites.h |   2 +
 test/cmd/Makefile     |   1 +
 test/cmd/setexpr.c    | 384 ++++++++++++++++++++++++++++++++++++++++++
 test/cmd_ut.c         |   3 +
 9 files changed, 664 insertions(+), 115 deletions(-)
 create mode 100644 test/cmd/setexpr.c

-- 
2.29.1.341.ge80a0c044ae-goog



More information about the U-Boot mailing list