[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_A14550789892F6FF07481AB3762E0D470E06@qq.com>
Date: Thu, 9 Dec 2021 17:39:31 +0800
From: x2018 <xkernel.wang@...mail.com>
To: dhowells@...hat.com, marc.dionne@...istor.com
Cc: linux-afs@...ts.infradead.org, linux-kernel@...r.kernel.org,
xkernel.wang@...mail.com
Subject: [PATCH] afs: fix a potential dead cycle and add a check for the return value of memchr()
From: xkernel <xkernel.wang@...mail.com>
We should make the address pointed by p plus 1, otherwise, it will fall
into a dead circle. And memchr() can return NULL if the target character
is not found, so it is better to check the return value of it.
Signed-off-by: xkernel <xkernel.wang@...mail.com>
---
fs/afs/addr_list.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/afs/addr_list.c b/fs/afs/addr_list.c
index de1ae0b..83e6171 100644
--- a/fs/afs/addr_list.c
+++ b/fs/afs/addr_list.c
@@ -90,8 +90,10 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net,
problem = "nul";
goto inval;
}
- if (*p == delim)
+ if (*p == delim) {
+ p++;
continue;
+ }
nr++;
if (*p == '[') {
p++;
@@ -146,6 +148,10 @@ struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net,
if (*p == '[') {
p++;
q = memchr(p, ']', end - p);
+ if (!q) {
+ problem = "brace2";
+ goto bad_address;
+ }
} else {
for (q = p; q < end; q++)
if (*q == '+' || *q == delim)
--
2.25.1
Powered by blists - more mailing lists