diff options
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r-- | lib/vsprintf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index dd7cc7fa3e77..6897724ff5df 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -620,11 +620,15 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width, | |||
620 | int precision, int flags) | 620 | int precision, int flags) |
621 | { | 621 | { |
622 | char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */ | 622 | char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */ |
623 | char temp[3]; /* hold each IP quad in reverse order */ | ||
623 | char *p = ip4_addr; | 624 | char *p = ip4_addr; |
624 | int i; | 625 | int i, digits; |
625 | 626 | ||
626 | for (i = 0; i < 4; i++) { | 627 | for (i = 0; i < 4; i++) { |
627 | p = put_dec_trunc(p, addr[i]); | 628 | digits = put_dec_trunc(temp, addr[i]) - temp; |
629 | /* reverse the digits in the quad */ | ||
630 | while (digits--) | ||
631 | *p++ = temp[digits]; | ||
628 | if (i != 3) | 632 | if (i != 3) |
629 | *p++ = '.'; | 633 | *p++ = '.'; |
630 | } | 634 | } |