summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2016-05-17 14:45:28 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-05-18 01:27:45 -0700
commitf2d57a8972f89f089f80dd0e4efeb6806d71806c (patch)
tree90aabed8657f2dd5c970fd4c9764ea9a243e2d3d /include
parent5c9fc1111c30eeacbd8474d5b80b1883def378d3 (diff)
downloadchrome-ec-f2d57a8972f89f089f80dd0e4efeb6806d71806c.tar.gz
do not allow console commands with names longer than 14 characters
The maximum length of console command name is hardcoded to be 14 in a few places in the code. In any case, 14 characters should be enough for any command name, let's add compile time check to ensure that this limit is honored. BRANCH=none BUG=none TEST=tried adding a command with a name longer than 14 characters, got a compile error. Change-Id: I11891fcd04983a5618400a602d4b80a478ecf3a9 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/345571 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/console.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/console.h b/include/console.h
index 75bbd6a335..f1f06b19bd 100644
--- a/include/console.h
+++ b/include/console.h
@@ -109,12 +109,16 @@ void console_has_input(void);
#elif defined(CONFIG_CONSOLE_CMDHELP)
#define DECLARE_CONSOLE_COMMAND(name, routine, argdesc, shorthelp, longhelp) \
static const char __con_cmd_label_##name[] = #name; \
+ struct size_check##name { \
+ int field[2 * (sizeof(__con_cmd_label_##name) < 16) - 1]; }; \
const struct console_command __keep __con_cmd_##name \
__attribute__((section(".rodata.cmds." #name))) \
= {__con_cmd_label_##name, routine, argdesc, shorthelp}
#else
#define DECLARE_CONSOLE_COMMAND(name, routine, argdesc, shorthelp, longhelp) \
static const char __con_cmd_label_##name[] = #name; \
+ struct size_check##name { \
+ int field[2 * (sizeof(__con_cmd_label_##name) < 16) - 1]; }; \
const struct console_command __keep __con_cmd_##name \
__attribute__((section(".rodata.cmds." #name))) \
= {__con_cmd_label_##name, routine}