Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
bf854df6
Unverified
Commit
bf854df6
authored
Mar 27, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vcc_acl: flexelint
Ref
aff516b7
f65f7148
parent
a3664ead
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
11 deletions
+24
-11
vcc_acl.c
lib/libvcc/vcc_acl.c
+24
-11
No files found.
lib/libvcc/vcc_acl.c
View file @
bf854df6
...
...
@@ -54,7 +54,7 @@ struct acl_e {
unsigned
not
;
unsigned
para
;
char
*
addr
;
c
har
*
fixed
;
c
onst
char
*
fixed
;
struct
token
*
t_addr
;
struct
token
*
t_mask
;
};
...
...
@@ -69,6 +69,16 @@ struct acl_e {
return (1); \
} while (0)
static
void
vcl_acl_free
(
struct
acl_e
**
aep
)
{
AN
(
aep
);
CHECK_OBJ_NOTNULL
(
*
aep
,
VCC_ACL_E_MAGIC
);
if
((
*
aep
)
->
addr
!=
NULL
)
free
((
*
aep
)
->
addr
);
FREE_OBJ
(
*
aep
);
}
static
int
vcl_acl_cmp
(
const
struct
acl_e
*
ae1
,
const
struct
acl_e
*
ae2
)
{
...
...
@@ -159,7 +169,7 @@ vcc_acl_chk(struct vcc *tl, const struct acl_e *ae, const int l,
return
(
strdup
(
t
));
}
static
void
static
struct
acl_e
*
vcc_acl_insert_entry
(
struct
vcc
*
tl
,
struct
acl_e
*
aen
)
{
struct
acl_e
*
ae2
;
...
...
@@ -173,12 +183,12 @@ vcc_acl_insert_entry(struct vcc *tl, struct acl_e *aen)
VSB_cat
(
tl
->
sb
,
"vs:
\n
"
);
vcc_ErrWhere
(
tl
,
aen
->
t_addr
);
}
FREE_OBJ
(
aen
);
return
;
return
(
NULL
);
}
return
(
aen
);
}
static
void
static
struct
acl_e
*
vcc_acl_add_entry
(
struct
vcc
*
tl
,
const
struct
acl_e
*
ae
,
int
l
,
unsigned
char
*
u
,
int
fam
)
{
...
...
@@ -191,17 +201,18 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
vcc_ErrWhere
(
tl
,
ae
->
t_mask
);
else
vcc_ErrWhere
(
tl
,
ae
->
t_addr
);
return
;
return
(
NULL
)
;
}
if
(
fam
==
PF_INET6
&&
ae
->
mask
>
128
)
{
VSB_printf
(
tl
->
sb
,
"Too wide mask (/%u) for IPv6 address
\n
"
,
ae
->
mask
);
vcc_ErrWhere
(
tl
,
ae
->
t_mask
);
return
;
return
(
NULL
)
;
}
/* Make a copy from the template */
ALLOC_OBJ
(
aen
,
VCC_ACL_E_MAGIC
);
AN
(
aen
);
*
aen
=
*
ae
;
aen
->
fixed
=
vcc_acl_chk
(
tl
,
ae
,
l
,
u
,
fam
);
...
...
@@ -214,7 +225,9 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l,
assert
(
l
+
1UL
<=
sizeof
aen
->
data
);
memcpy
(
aen
->
data
+
1L
,
u
,
l
);
vcc_acl_insert_entry
(
tl
,
aen
);
if
(
vcc_acl_insert_entry
(
tl
,
aen
)
==
NULL
)
vcl_acl_free
(
&
aen
);
return
(
aen
);
}
static
void
...
...
@@ -288,7 +301,7 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae)
u
=
(
void
*
)
&
sin4
->
sin_addr
;
if
(
ae
->
t_mask
==
NULL
)
ae
->
mask
=
32
;
vcc_acl_add_entry
(
tl
,
ae
,
4
,
u
,
res
->
ai_family
);
(
void
)
vcc_acl_add_entry
(
tl
,
ae
,
4
,
u
,
res
->
ai_family
);
break
;
case
PF_INET6
:
assert
(
PF_INET6
<
256
);
...
...
@@ -297,7 +310,7 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae)
u
=
(
void
*
)
&
sin6
->
sin6_addr
;
if
(
ae
->
t_mask
==
NULL
)
ae
->
mask
=
128
;
vcc_acl_add_entry
(
tl
,
ae
,
16
,
u
,
res
->
ai_family
);
(
void
)
vcc_acl_add_entry
(
tl
,
ae
,
16
,
u
,
res
->
ai_family
);
break
;
default
:
continue
;
...
...
@@ -343,7 +356,7 @@ vcc_acl_try_netnotation(struct vcc *tl, struct acl_e *ae)
}
if
(
ae
->
t_mask
==
NULL
)
ae
->
mask
=
8
+
8
*
i
;
vcc_acl_add_entry
(
tl
,
ae
,
4
,
b
,
AF_INET
);
(
void
)
vcc_acl_add_entry
(
tl
,
ae
,
4
,
b
,
AF_INET
);
return
(
1
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment