diff options
author | Jan Beulich <JBeulich@suse.com> | 2012-03-05 11:49:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-06 11:22:26 -0500 |
commit | 5756b76e4db643d8f75174a9a50038523d4b9e32 (patch) | |
tree | 62873627752df2dd08b244e983b1cd89e31b72ee /lib/vsprintf.c | |
parent | c09ff089aa62380ad904ea785bd713c56720270e (diff) |
vsprintf: make %pV handling compatible with kasprintf()
kasprintf() (and potentially other functions that I didn't run across so
far) want to evaluate argument lists twice. Caring to do so for the
primary list is obviously their job, but they can't reasonably be
expected to check the format string for instances of %pV, which however
need special handling too: On architectures like x86-64 (as opposed to
e.g. ix86), using the same argument list twice doesn't produce the
expected results, as an internally managed cursor gets updated during
the first run.
Fix the problem by always acting on a copy of the original list when
handling %pV.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r-- | lib/vsprintf.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8e75003d62f6..38e612e66da5 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -891,9 +891,15 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
891 | case 'U': | 891 | case 'U': |
892 | return uuid_string(buf, end, ptr, spec, fmt); | 892 | return uuid_string(buf, end, ptr, spec, fmt); |
893 | case 'V': | 893 | case 'V': |
894 | return buf + vsnprintf(buf, end > buf ? end - buf : 0, | 894 | { |
895 | ((struct va_format *)ptr)->fmt, | 895 | va_list va; |
896 | *(((struct va_format *)ptr)->va)); | 896 | |
897 | va_copy(va, *((struct va_format *)ptr)->va); | ||
898 | buf += vsnprintf(buf, end > buf ? end - buf : 0, | ||
899 | ((struct va_format *)ptr)->fmt, va); | ||
900 | va_end(va); | ||
901 | return buf; | ||
902 | } | ||
897 | case 'K': | 903 | case 'K': |
898 | /* | 904 | /* |
899 | * %pK cannot be used in IRQ context because its test | 905 | * %pK cannot be used in IRQ context because its test |