diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 3ab8c9cf3980..4da1e7aaf9d5 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -777,11 +777,19 @@ char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec, | |||
777 | if (spec.field_width > 0) | 777 | if (spec.field_width > 0) |
778 | len = min_t(int, spec.field_width, 64); | 778 | len = min_t(int, spec.field_width, 64); |
779 | 779 | ||
780 | for (i = 0; i < len && buf < end - 1; i++) { | 780 | for (i = 0; i < len; ++i) { |
781 | buf = hex_byte_pack(buf, addr[i]); | 781 | if (buf < end) |
782 | *buf = hex_asc_hi(addr[i]); | ||
783 | ++buf; | ||
784 | if (buf < end) | ||
785 | *buf = hex_asc_lo(addr[i]); | ||
786 | ++buf; | ||
782 | 787 | ||
783 | if (buf < end && separator && i != len - 1) | 788 | if (separator && i != len - 1) { |
784 | *buf++ = separator; | 789 | if (buf < end) |
790 | *buf = separator; | ||
791 | ++buf; | ||
792 | } | ||
785 | } | 793 | } |
786 | 794 | ||
787 | return buf; | 795 | return buf; |