diff mbox series

tipc: fix a log bug

Message ID 20230423035545.3528996-1-sunyiqixm@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series tipc: fix a log bug | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang fail Errors and warnings before: 13 this patch: 13
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 14 this patch: 14
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

sunyiqi April 23, 2023, 3:55 a.m. UTC
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(-)

Comments

Tung Quang Nguyen April 24, 2023, 11 a.m. UTC | #1
>Subject: [PATCH] tipc: fix a log bug
Please rephrase this patch title, what is "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.
>
Please rephrase this change log by correcting typo/grammar and provide printouts of "tipc node list" command to prove unexpected/incorrect node id.
>Signed-off-by: sunichi <sunyiqixm@gmail.com>
If you can prove there is a bug, please add Fixes tag to your patch.
>---
> 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
diff mbox series

Patch

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;
 }