Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
551b0fe1
Commit
551b0fe1
authored
Apr 21, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't used fixed-size buffers to read config files, unless we have
to due to absence of getline()
parent
cb2cdd4f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
configure.ac
configure.ac
+1
-0
config.c
src/config.c
+34
-6
No files found.
configure.ac
View file @
551b0fe1
...
...
@@ -199,6 +199,7 @@ AC_CHECK_FUNCS([abort2])
AC_CHECK_FUNCS([timegm])
AC_CHECK_FUNCS([nanosleep])
AC_CHECK_FUNCS([setppriv])
AC_CHECK_FUNCS([getline])
save_LIBS="${LIBS}"
LIBS="${PTHREAD_LIBS}"
...
...
src/config.c
View file @
551b0fe1
...
...
@@ -41,6 +41,8 @@
#include <unistd.h>
#include <pwd.h>
#include "config.h"
#include "varnishevent.h"
#include "vtim.h"
...
...
@@ -252,10 +254,24 @@ CONF_Init(void)
config
.
gid
=
pw
->
pw_gid
;
}
static
int
conf_get_line
(
char
*
line
,
FILE
*
in
)
{
#ifdef HAVE_GETLINE
size_t
n
=
BUFSIZ
;
errno
=
0
;
return
(
getline
(
&
line
,
&
n
,
in
));
#else
if
(
fgets
(
line
,
BUFSIZ
,
in
)
==
NULL
)
return
-
1
;
return
0
;
#endif
}
int
CONF_ReadFile
(
const
char
*
file
)
{
FILE
*
in
;
char
line
[
BUFSIZ
]
;
char
*
line
;
int
linenum
=
0
;
in
=
fopen
(
file
,
"r"
);
...
...
@@ -264,7 +280,9 @@ CONF_ReadFile(const char *file) {
return
(
-
1
);
}
while
(
fgets
(
line
,
BUFSIZ
,
in
)
!=
NULL
)
{
line
=
(
char
*
)
malloc
(
BUFSIZ
);
AN
(
line
);
while
(
conf_get_line
(
line
,
in
)
!=
-
1
)
{
char
orig
[
BUFSIZ
];
linenum
++
;
...
...
@@ -299,8 +317,18 @@ CONF_ReadFile(const char *file) {
return
(
-
1
);
}
}
fclose
(
in
);
return
(
0
);
int
ret
=
0
;
if
(
ferror
(
in
))
{
fprintf
(
stderr
,
"Error reading file %s (errno %d: %s)
\n
"
,
file
,
errno
,
strerror
(
errno
));
ret
=
-
1
;
}
errno
=
0
;
if
(
fclose
(
in
)
!=
0
)
{
fprintf
(
stderr
,
"Error closing file %s: %s)
\n
"
,
file
,
strerror
(
errno
));
ret
=
-
1
;
}
return
(
ret
);
}
#define confdump(str,val) \
...
...
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