summaryrefslogtreecommitdiffstats
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-11-03 17:09:55 -0800
committerDavid S. Miller <davem@davemloft.net>2008-11-03 17:09:55 -0800
commitb9ac99855dcc0316ba2feee2b0d3e578f8315b75 (patch)
tree7ca8a4864a3a8f29bc53ab705954c7e7220d2686 /lib/vsprintf.c
parent48148938b494cd57029a43c758e9972307a31d2a (diff)
printk: ipv4 address digits printed in reverse order
put_dec_trunc prints the digits in reverse order and is reversed inside number(). Continue using put_dec_trunc, but reverse each quad in ip4_addr_string. [Noticed by Julius Volz] Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index dd7cc7fa3e7..6897724ff5d 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,
int precision, int flags)
{
char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */
+ char temp[3]; /* hold each IP quad in reverse order */
char *p = ip4_addr;
- int i;
+ int i, digits;
for (i = 0; i < 4; i++) {
- p = put_dec_trunc(p, addr[i]);
+ digits = put_dec_trunc(temp, addr[i]) - temp;
+ /* reverse the digits in the quad */
+ while (digits--)
+ *p++ = temp[digits];
if (i != 3)
*p++ = '.';
}