提交 4e310fda 编写于 作者: J Joe Perches 提交者: Linus Torvalds

vsprintf: Change struct printf_spec.precision from s8 to s16

Commit ef0658f3 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: NEric Paris <eparis@redhat.com>
Signed-off-by: NJoe Perches <joe@perches.com>
Tested-by: NJustin P. Mattock <justinmattock@gmail.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 2ba3abd8
......@@ -408,12 +408,12 @@ enum format_type {
};
struct printf_spec {
u16 type;
s16 field_width; /* width of output field */
u8 type; /* format_type enum */
u8 flags; /* flags to number() */
u8 base;
s8 precision; /* # of digits/chars */
u8 qualifier;
u8 base; /* number base, 8, 10 or 16 only */
u8 qualifier; /* number qualifier, one of 'hHlLtzZ' */
s16 field_width; /* width of output field */
s16 precision; /* # of digits/chars */
};
static char *number(char *buf, char *end, unsigned long long num,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册