[U-Boot] [PATCH 02/14] sandbox: Move CONFIG_SYS_VSNPRINTF to Kconfig

Simon Glass sjg at chromium.org
Fri Mar 6 21:19:02 CET 2015


Move this over to Kconfig and tidy up.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/x86/Kconfig             | 3 +++
 configs/sandbox_defconfig    | 1 +
 include/configs/sandbox.h    | 2 --
 include/configs/x86-common.h | 1 -
 lib/Kconfig                  | 9 +++++++++
 5 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 78a0532..2deadb2 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -7,6 +7,9 @@ config SYS_ARCH
 config USE_PRIVATE_LIBGCC
 	default y
 
+config SYS_VSNPRINTF
+	default y
+
 choice
 	prompt "Target select"
 
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 15d13b5..a6c3252 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -14,3 +14,4 @@ CONFIG_CROS_EC_KEYB=y
 CONFIG_CMD_CROS_EC=y
 CONFIG_BOOTSTAGE=y
 CONFIG_SANDBOX_GPIO=y
+CONFIG_SYS_VSNPRINTF=y
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index a880acb..8d96999 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -46,8 +46,6 @@
 #define CONFIG_CMD_FS_GENERIC
 #define CONFIG_CMD_MD5SUM
 
-#define CONFIG_SYS_VSNPRINTF
-
 #define CONFIG_CMD_GPIO
 
 #define CONFIG_CMD_GPT
diff --git a/include/configs/x86-common.h b/include/configs/x86-common.h
index 75108a9..d89fdca 100644
--- a/include/configs/x86-common.h
+++ b/include/configs/x86-common.h
@@ -16,7 +16,6 @@
  * (easy to change)
  */
 #define CONFIG_SHOW_BOOT_PROGRESS
-#define CONFIG_SYS_VSNPRINTF
 #define CONFIG_ZBOOT_32
 #define CONFIG_PHYSMEM
 #define CONFIG_DISPLAY_BOARDINFO_LATE
diff --git a/lib/Kconfig b/lib/Kconfig
index c9d2767..d7fd219 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -27,6 +27,15 @@ config SYS_HZ
 	  get_timer() must operate in milliseconds and this option must be
 	  set to 1000.
 
+config SYS_VSNPRINTF
+	bool "Enable safe version of sprintf()"
+	help
+	  Since sprintf() can overflow its buffer, it is common to use
+	  snprintf() instead, which knows the buffer size and can avoid
+	  overflow. However, this does increase code size slightly (for
+	  Thumb-2, about 420 bytes). Enable this option for safety when
+	  using sprintf() with data you do not control.
+
 source lib/rsa/Kconfig
 
 menu "Hashing Support"
-- 
2.2.0.rc0.207.ga3a616c



More information about the U-Boot mailing list