entry.c:396 load_entry() info: redundant null check on e->pwd calling free()
entry.c:398 load_entry() info: redundant null check on e->cmd calling free()
/usr/include/bits/fcntl.h:48:10: warning: preprocessor token O_NOFOLLOW redefined
macros.h:136:9: this was the original definition
security.c:98:44: warning: non-ANSI function declaration of function
'cron_restore_default_security_context'
crontab.c:439:29: warning: non-ANSI function declaration of function 'tmp_path'
Signed-off-by: Sami Kerola <kerolasa(a)iki.fi>
---
configure.ac | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/crontab.c | 2 +-
src/entry.c | 6 ++----
src/macros.h | 2 +-
src/security.c | 2 +-
5 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index c514e34..4b5d600 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,51 @@ AC_CHECK_FUNCS( \
fchgrp \
)
+# Most of the gl_FCNTL_O_FLAGS is copied from gnulib.
+AC_DEFUN([gl_FCNTL_O_FLAGS], [
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+ AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+ #ifndef O_NOFOLLOW
+ #define O_NOFOLLOW 0
+ #endif
+ static int const constants[] =
+ {
+ O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
+ O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
+ };
+ ]],
+ [[
+ int status = !constants;
+ {
+ static char const sym[] = "conftest.sym";
+ if (symlink (".", sym) != 0
+ || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
+ status |= 32;
+ unlink (sym);
+ }
+ return status;]])],
+ [gl_cv_header_working_fcntl_h=yes],
+ [case $? in #(
+ 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
+ *) gl_cv_header_working_fcntl_h='no';;
+ esac],
+ [gl_cv_header_working_fcntl_h=cross-compiling])])
+
+ case $gl_cv_header_working_fcntl_h in #(
+ *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
+ *) ac_val=1;;
+ esac
+ AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
+ [Define to 1 if O_NOFOLLOW works.])
+])
+gl_FCNTL_O_FLAGS
+
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIGNAL
diff --git a/src/crontab.c b/src/crontab.c
index 28e75a0..5592939 100644
--- a/src/crontab.c
+++ b/src/crontab.c
@@ -438,7 +438,7 @@ static void check_error(const char *msg) {
fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber - 1, msg);
}
-static const char *tmp_path() {
+static const char *tmp_path(void) {
const char *tmpdir = NULL;
if ((getuid() == geteuid()) && (getgid() == getegid())) {
diff --git a/src/entry.c b/src/entry.c
index 0b482b9..e9142f5 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -392,10 +392,8 @@ entry *load_entry(FILE * file, void (*error_func) (), struct passwd
*pw,
eof:
if (e->envp)
env_free(e->envp);
- if (e->pwd)
- free(e->pwd);
- if (e->cmd)
- free(e->cmd);
+ free(e->pwd);
+ free(e->cmd);
free(e);
while (ch != '\n' && !feof(file))
ch = get_char(file);
diff --git a/src/macros.h b/src/macros.h
index b3f4010..4d1bfd8 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -132,7 +132,7 @@
* we will just have to live without it. In order for this to be an
* issue an attacker would have to subvert group CRON_GROUP.
*/
-#ifndef O_NOFOLLOW
+#if (HAVE_WORKING_O_NOFOLLOW == 0)
#define O_NOFOLLOW 0
#endif
diff --git a/src/security.c b/src/security.c
index 7639891..7724b2f 100644
--- a/src/security.c
+++ b/src/security.c
@@ -97,7 +97,7 @@ static int cron_get_job_range(user * u, security_context_t * ucontextp,
char **jobenv);
#endif
-void cron_restore_default_security_context() {
+void cron_restore_default_security_context(void) {
#ifdef WITH_SELINUX
setexeccon(NULL);
#endif
--
1.8.0.1