* [PATCH] afs: fix a potential dead cycle and add a check for the return value of memchr()
@ 2021-12-09 9:39 x2018
0 siblings, 0 replies; 2+ messages in thread
From: x2018 @ 2021-12-09 9:39 UTC (permalink / raw)
To: dhowells, marc.dionne; +Cc: linux-afs, linux-kernel, xkernel.wang
From: xkernel <xkernel.wang@foxmail.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@foxmail.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] afs: fix a potential dead cycle and add a check for the return value of memchr()
@ 2021-12-13 7:12 Xiaoke Wang
0 siblings, 0 replies; 2+ messages in thread
From: Xiaoke Wang @ 2021-12-13 7:12 UTC (permalink / raw)
To: dhowells, marc.dionne; +Cc: linux-afs, linux-kernel, Xiaoke Wang
Note: this email is using full name
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: Xiaoke Wang <xkernel.wang@foxmail.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)
--
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-13 7:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 9:39 [PATCH] afs: fix a potential dead cycle and add a check for the return value of memchr() x2018
2021-12-13 7:12 Xiaoke Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).