svn commit: r308160 - in head: etc etc/mtree usr.sbin/syslogd

Conrad Meyer cem at freebsd.org
Tue Nov 8 17:02:38 UTC 2016


On Mon, Oct 31, 2016 at 6:41 PM, Baptiste Daroussin <bapt at freebsd.org> wrote:
> Author: bapt
> Date: Tue Nov  1 01:41:24 2016
> New Revision: 308160
> URL: https://svnweb.freebsd.org/changeset/base/308160
>
> Log:
>   syslogd(8): add an 'include' keyword
>
>   All the '.conf' files not beginning with a '.' contained int he directory
>   following the keyword will be included.
>
>   This keyword can only be used in the first level configuration files.
>
>   Modify the default syslogd.conf to 'include' /etc/syslog.d and
>   /usr/local/etc/syslog.d
>
>   It simplify a lot handling of syslog from automation tools.

This breaks some paths in init(), as pointed out by Coverity (CID
1365665).  See inline below.

>...
> Modified: head/usr.sbin/syslogd/syslogd.c
> ==============================================================================
> --- head/usr.sbin/syslogd/syslogd.c     Tue Nov  1 01:19:48 2016        (r308159)
> +++ head/usr.sbin/syslogd/syslogd.c     Tue Nov  1 01:41:24 2016        (r308160)
> ...
> @@ -1601,6 +1604,157 @@ die(int signo)
> ...
>  /*
>   *  INIT -- Initialize syslogd from configuration table
>   */
> @@ -1611,9 +1765,6 @@ init(int signo)
>         FILE *cf;
>         struct filed *f, *next, **nextp;
>         char *p;
> -       char cline[LINE_MAX];
> -       char prog[LINE_MAX];
> -       char host[MAXHOSTNAMELEN];
>         char oldLocalHostName[MAXHOSTNAMELEN];
>         char hostMsg[2*MAXHOSTNAMELEN+40];
>         char bootfileMsg[LINE_MAX];
> @@ -1684,7 +1835,6 @@ init(int signo)
>                 free((char *)f);
>         }
>         Files = NULL;
> -       nextp = &Files;

This line leaves nextp uninitialized in init().

>
>         /* open the configuration file */
>         if ((cf = fopen(ConfFile, "r")) == NULL) {

Nextp is used in init() between these two hunks:

1838
1839         /* open the configuration file */
1840         if ((cf = fopen(ConfFile, "r")) == NULL) {
1841                 dprintf("cannot open %s\n", ConfFile);
1842                 *nextp = (struct filed *)calloc(1, sizeof(*f));
   <<<< now bogus
1843                 if (*nextp == NULL) {
1844                         logerror("calloc");
1845                         exit(1);
1846                 }
1847                 cfline("*.ERR\t/dev/console", *nextp, "*", "*");
1848                 (*nextp)->f_next = (struct filed *)calloc(1, sizeof(*f));
1849                 if ((*nextp)->f_next == NULL) {
1850                         logerror("calloc");
1851                         exit(1);
1852                 }
1853                 cfline("*.PANIC\t*", (*nextp)->f_next, "*", "*");
1854                 Initialized = 1;
1855                 return;
1856         }


> @@ -1705,83 +1855,7 @@ init(int signo)
> ...

Thanks,
Conrad


More information about the svn-src-head mailing list