From: sunichi <sunyiqixm@gmail.com>
To: jmaloy@redhat.com
Cc: ying.xue@windriver.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org, sunichi <sunyiqixm@gmail.com>
Subject: [PATCH] tipc: fix a log bug
Date: Sun, 23 Apr 2023 11:55:45 +0800 [thread overview]
Message-ID: <20230423035545.3528996-1-sunyiqixm@gmail.com> (raw)
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
next reply other threads:[~2023-04-23 3:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-23 3:55 sunichi [this message]
2023-04-24 11:00 ` Tung Quang Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230423035545.3528996-1-sunyiqixm@gmail.com \
--to=sunyiqixm@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=ying.xue@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®