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
69897c6b
Commit
69897c6b
authored
May 21, 2016
by
Poul-Henning Kamp
Committed by
Lasse Karstensen
Jun 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate a NULL pointer issue with empty (apart from comments and
whitespace) testfiles. Spotted by: Coverity
parent
fc6790d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
35 deletions
+47
-35
vtc_main.c
bin/varnishtest/vtc_main.c
+47
-35
No files found.
bin/varnishtest/vtc_main.c
View file @
69897c6b
...
...
@@ -428,6 +428,50 @@ dns_works(void)
return
(
1
);
}
/**********************************************************************
* Main
*/
static
int
read_file
(
const
char
*
fn
,
int
ntest
)
{
struct
vtc_tst
*
tp
;
char
*
p
;
p
=
VFIL_readfile
(
NULL
,
fn
,
NULL
);
if
(
p
==
NULL
)
{
fprintf
(
stderr
,
"Cannot stat file
\"
%s
\"
: %s
\n
"
,
fn
,
strerror
(
errno
));
return
(
2
);
}
for
(;
p
!=
NULL
&&
*
p
!=
'\0'
;
p
++
)
{
if
(
vct_islws
(
*
p
))
continue
;
if
(
*
p
!=
'#'
)
break
;
p
=
strchr
(
p
,
'\n'
);
}
if
(
p
==
NULL
||
*
p
==
'\0'
)
{
fprintf
(
stderr
,
"File
\"
%s
\"
has no content.
\n
"
,
fn
);
return
(
2
);
}
if
(
strncmp
(
p
,
"varnishtest"
,
11
)
||
!
isspace
(
p
[
11
]))
{
fprintf
(
stderr
,
"File
\"
%s
\"
doesn't start with 'varnishtest'
\n
"
,
fn
);
return
(
2
);
}
ALLOC_OBJ
(
tp
,
TST_MAGIC
);
AN
(
tp
);
tp
->
filename
=
fn
;
tp
->
script
=
p
;
tp
->
ntodo
=
ntest
;
VTAILQ_INSERT_TAIL
(
&
tst_head
,
tp
,
list
);
return
(
0
);
}
/**********************************************************************
* Main
*/
...
...
@@ -437,8 +481,6 @@ main(int argc, char * const *argv)
{
int
ch
,
i
;
int
ntest
=
1
;
/* Run tests this many times */
struct
vtc_tst
*
tp
;
char
*
p
;
uintmax_t
bufsiz
;
/* Default names of programs */
...
...
@@ -523,40 +565,10 @@ main(int argc, char * const *argv)
argv
+=
optind
;
for
(;
argc
>
0
;
argc
--
,
argv
++
)
{
p
=
VFIL_readfile
(
NULL
,
*
argv
,
NULL
);
if
(
p
==
NULL
)
{
fprintf
(
stderr
,
"Cannot stat file
\"
%s
\"
: %s
\n
"
,
*
argv
,
strerror
(
errno
));
if
(
vtc_continue
)
continue
;
exit
(
2
);
}
while
(
1
)
{
if
(
vct_islws
(
*
p
))
{
p
++
;
continue
;
}
if
(
*
p
==
'#'
)
{
if
((
p
=
strchr
(
p
,
'\n'
)))
p
++
;
continue
;
}
break
;
}
if
(
strncmp
(
p
,
"varnishtest"
,
11
)
||
!
isspace
(
p
[
11
]))
{
fprintf
(
stderr
,
"File
\"
%s
\"
doesn't start with 'varnishtest'
\n
"
,
*
argv
);
if
(
vtc_continue
)
continue
;
if
(
!
read_file
(
*
argv
,
ntest
))
continue
;
if
(
!
vtc_continue
)
exit
(
2
);
}
ALLOC_OBJ
(
tp
,
TST_MAGIC
);
AN
(
tp
);
tp
->
filename
=
*
argv
;
tp
->
script
=
p
;
tp
->
ntodo
=
ntest
;
VTAILQ_INSERT_TAIL
(
&
tst_head
,
tp
,
list
);
}
feature_dns
=
dns_works
();
...
...
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