diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-01-29 10:52:17 +0000 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-01-29 10:52:17 +0000 |
commit | 45ce6547e6bde8cdf8f3dcaba833a3bda8f3c889 (patch) | |
tree | 9ce439909a9e3816fbac7b29bac84009fced953e /xen/common/symbols.c | |
parent | c642ec17d0d541835334b676e972539fdd5becdc (diff) | |
download | xen-45ce6547e6bde8cdf8f3dcaba833a3bda8f3c889.tar.gz xen-45ce6547e6bde8cdf8f3dcaba833a3bda8f3c889.tar.bz2 xen-45ce6547e6bde8cdf8f3dcaba833a3bda8f3c889.zip |
Replace sprintf with snprintf and strncpy with strlcpy.
There are various cases where no NULL-terminated strings are
guaranteed and eventual possible overflows. This patch fixes them.
From: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/common/symbols.c')
-rw-r--r-- | xen/common/symbols.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/xen/common/symbols.c b/xen/common/symbols.c index fba6cf0867..f4134b7ed5 100644 --- a/xen/common/symbols.c +++ b/xen/common/symbols.c @@ -142,15 +142,17 @@ void __print_symbol(const char *fmt, unsigned long address) const char *name; unsigned long offset, size; char namebuf[KSYM_NAME_LEN+1]; - char buffer[sizeof("%s+%#lx/%#lx [%s]") + KSYM_NAME_LEN + - 2*(BITS_PER_LONG*3/10) + 1]; + +#define BUFFER_SIZE sizeof("%s+%#lx/%#lx [%s]") + KSYM_NAME_LEN + \ + 2*(BITS_PER_LONG*3/10) + 1 + char buffer[BUFFER_SIZE]; name = symbols_lookup(address, &size, &offset, namebuf); if (!name) - sprintf(buffer, "???"); + snprintf(buffer, BUFFER_SIZE, "???"); else - sprintf(buffer, "%s+%#lx/%#lx", name, offset, size); + snprintf(buffer, BUFFER_SIZE, "%s+%#lx/%#lx", name, offset, size); printk(fmt, buffer); } |