mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tipc: fix a log bug
@ 2023-04-23  3:55 sunichi
  2023-04-24 11:00 ` Tung Quang Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: sunichi @ 2023-04-23  3:55 UTC (permalink / raw)
  To: jmaloy
  Cc: ying.xue, davem, edumazet, kuba, pabeni, netdev, tipc-discussion,
	linux-kernel, sunichi

When tipc stripe \x00 from string hex, it walks step by step
instead of two step.
It will cause a char which ascii low 4 bit is zero be striped.
So change one step iteration to two step to fix this bug.

Signed-off-by: sunichi <sunyiqixm@gmail.com>
---
 net/tipc/addr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/tipc/addr.c b/net/tipc/addr.c
index fd0796269..83eb91ca3 100644
--- a/net/tipc/addr.c
+++ b/net/tipc/addr.c
@@ -117,8 +117,10 @@ char *tipc_nodeid2string(char *str, u8 *id)
 		sprintf(&str[2 * i], "%02x", id[i]);
 
 	/* Strip off trailing zeroes */
-	for (i = NODE_ID_STR_LEN - 2; str[i] == '0'; i--)
+	for (i = NODE_ID_STR_LEN - 2; str[i] == '0' && str[i - 1] == '0'; i -= 2) {
 		str[i] = 0;
+		str[i - 1] = 0;
+	}
 
 	return str;
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-24 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-23  3:55 [PATCH] tipc: fix a log bug sunichi
2023-04-24 11:00 ` Tung Quang Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®