Skip to contentSkip to conversation

tipc: fix a log bug

PATCH In review sunichi 2 participants 2 messages Apr 23, 2023 – Apr 24, 2023

Subsystems (3)
lore
Share & tools
lore

sunichi

author
#0 lore raw

PATCH 1/1 tipc: fix a log bug

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.

---
 net/tipc/addr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/tipc/addr.c +3 -1
index fd0796269..83eb91ca3 100644
@@ -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;
 }
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines

Subject: [PATCH] tipc: fix a log bug

Please rephrase this patch title, what is "log bug" ?

Quoted 6 lines

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.

Please rephrase this change log by correcting typo/grammar and provide printouts of "tipc node list" command to prove unexpected/incorrect node id.

Quoted 1 line

If you can prove there is a bug, please add Fixes tag to your patch.

Quoted 22 lines

---
net/tipc/addr.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
net/tipc/addr.c +3 -2
index fd0796269..83eb91ca3 100644
@@ -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