aboutsummaryrefslogtreecommitdiff
path: root/include/command.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-11-01 14:15:40 -0700
committerTom Rini <trini@konsulko.com>2020-12-01 10:33:38 -0500
commitd422c77ae8e0cb1211b34eb4af442600b0da8d5b (patch)
tree461c03c29dce244867eb635eced3050880eec946 /include/command.h
parent56331b2680d9fef7e60a88fa50d3e167f236c4a0 (diff)
downloadu-boot-d422c77ae8e0cb1211b34eb4af442600b0da8d5b.zip
u-boot-d422c77ae8e0cb1211b34eb4af442600b0da8d5b.tar.gz
u-boot-d422c77ae8e0cb1211b34eb4af442600b0da8d5b.tar.bz2
setexpr: Add some tests for buffer overflow and backref
Add tests to check for buffer overflow using simple replacement as well as back references. At present these don't fully pass. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/command.h')
-rw-r--r--include/command.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/command.h b/include/command.h
index e900f97..e229bf2 100644
--- a/include/command.h
+++ b/include/command.h
@@ -183,6 +183,23 @@ extern int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[]);
#endif
+/**
+ * setexpr_regex_sub() - Replace a regex pattern with a string
+ *
+ * @data: Buffer containing the string to update
+ * @data_size: Size of buffer (must be large enough for the new string)
+ * @nbuf: Back-reference buffer
+ * @nbuf_size: Size of back-reference buffer (must be larger enough for @s plus
+ * all back-reference expansions)
+ * @r: Regular expression to find
+ * @s: String to replace with
+ * @global: true to replace all matches in @data, false to replace just the
+ * first
+ * @return 0 if OK, 1 on error
+ */
+int setexpr_regex_sub(char *data, uint data_size, char *nbuf, uint nbuf_size,
+ const char *r, const char *s, bool global);
+
/*
* Error codes that commands return to cmd_process(). We use the standard 0
* and 1 for success and failure, but add one more case - failure with a