lkml.org 
[lkml]   [2021]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] afs: fix a potential dead cycle and add a check for the return value of memchr()
Date
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)
--
\
 
 \ /
  Last update: 2021-12-13 08:13    [W:0.087 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site