summaryrefslogtreecommitdiffstats
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2016-01-14 13:02:03 -0500
committerTom Rini <trini@konsulko.com>2016-01-19 08:31:16 -0500
commit947c626dc5bfbc232cc0f41d16fa213a885ad234 (patch)
tree4d1f6443abd9dd3cb74ab5a8abb6f7e7a46d82cc /lib/vsprintf.c
parent9c11135ce053904f4caadc27760f214425d9881a (diff)
downloadtalos-obmc-uboot-947c626dc5bfbc232cc0f41d16fa213a885ad234.tar.gz
talos-obmc-uboot-947c626dc5bfbc232cc0f41d16fa213a885ad234.zip
vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF
Enabling this function always removes some class of string saftey issues. The size change here in general is about 400 bytes and this seems a reasonable trade-off. Cc: Peng Fan <peng.fan@nxp.com> Cc: Peter Robinson <pbrobinson@gmail.com> Cc: Fabio Estevam <fabio.estevam@freescale.com> Cc: Adrian Alonso <aalonso@freescale.com> Cc: Stefano Babic <sbabic@denx.de> Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c12
1 files changed, 0 insertions, 12 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 24167a135c..874a2951f7 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -141,7 +141,6 @@ static noinline char *put_dec(char *buf, uint64_t num)
#define SMALL 32 /* Must be 32 == 0x20 */
#define SPECIAL 64 /* 0x */
-#ifdef CONFIG_SYS_VSNPRINTF
/*
* Macro to add a new character to our output string, but only if it will
* fit. The macro moves to the next character position in the output string.
@@ -151,9 +150,6 @@ static noinline char *put_dec(char *buf, uint64_t num)
*(str) = (ch); \
++str; \
} while (0)
-#else
-#define ADDCH(str, ch) (*(str)++ = (ch))
-#endif
static char *number(char *buf, char *end, u64 num,
int base, int size, int precision, int type)
@@ -441,13 +437,11 @@ static int vsnprintf_internal(char *buf, size_t size, const char *fmt,
/* 't' added for ptrdiff_t */
char *end = buf + size;
-#ifdef CONFIG_SYS_VSNPRINTF
/* Make sure end is always >= buf - do we want this in U-Boot? */
if (end < buf) {
end = ((void *)-1);
size = end - buf;
}
-#endif
str = buf;
for (; *fmt ; ++fmt) {
@@ -609,21 +603,16 @@ repeat:
flags);
}
-#ifdef CONFIG_SYS_VSNPRINTF
if (size > 0) {
ADDCH(str, '\0');
if (str > end)
end[-1] = '\0';
--str;
}
-#else
- *str = '\0';
-#endif
/* the trailing null byte doesn't count towards the total */
return str - buf;
}
-#ifdef CONFIG_SYS_VSNPRINTF
int vsnprintf(char *buf, size_t size, const char *fmt,
va_list args)
{
@@ -666,7 +655,6 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...)
return i;
}
-#endif /* CONFIG_SYS_VSNPRINT */
/**
* Format a string and place it in a buffer (va_list version)
OpenPOWER on IntegriCloud