diff options
author | Joe Perches <joe@perches.com> | 2010-04-14 12:27:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-04-14 13:32:35 -0400 |
commit | 4e310fda91cb095915395f811d10b2c900c9589e (patch) | |
tree | 5e4d6b2bd76abe6f2bb0db12d6d82f697007d1e5 | |
parent | 2ba3abd8186f24c7fb418927025b4e2120e3a362 (diff) |
vsprintf: Change struct printf_spec.precision from s8 to s16
Commit ef0658f3de484bf9b173639cd47544584e01efa5 changed precision
from int to s8.
There is existing kernel code that uses a larger precision.
An example from the audit code:
vsnprintf(...,..., " msg='%.1024s'", (char *)data);
which overflows precision and truncates to nothing.
Extending precision size fixes the audit system issue.
Other changes:
Change the size of the struct printf_spec.type from u16 to u8 so
sizeof(struct printf_spec) stays as small as possible.
Reorder the struct members so sizeof(struct printf_spec) remains 64 bits
without alignment holes.
Document the struct members a bit more.
Original-patch-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Joe Perches <joe@perches.com>
Tested-by: Justin P. Mattock <justinmattock@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | lib/vsprintf.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 24112e5a5780..7376b7c55ffe 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -408,12 +408,12 @@ enum format_type { | |||
408 | }; | 408 | }; |
409 | 409 | ||
410 | struct printf_spec { | 410 | struct printf_spec { |
411 | u16 type; | 411 | u8 type; /* format_type enum */ |
412 | s16 field_width; /* width of output field */ | ||
413 | u8 flags; /* flags to number() */ | 412 | u8 flags; /* flags to number() */ |
414 | u8 base; | 413 | u8 base; /* number base, 8, 10 or 16 only */ |
415 | s8 precision; /* # of digits/chars */ | 414 | u8 qualifier; /* number qualifier, one of 'hHlLtzZ' */ |
416 | u8 qualifier; | 415 | s16 field_width; /* width of output field */ |
416 | s16 precision; /* # of digits/chars */ | ||
417 | }; | 417 | }; |
418 | 418 | ||
419 | static char *number(char *buf, char *end, unsigned long long num, | 419 | static char *number(char *buf, char *end, unsigned long long num, |