Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Feb 2019 14:59:40 +0000 (UTC)
From:      David Bright <dab@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344468 - head/usr.sbin/newsyslog
Message-ID:  <201902221459.x1MExegD026299@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dab
Date: Fri Feb 22 14:59:40 2019
New Revision: 344468
URL: https://svnweb.freebsd.org/changeset/base/344468

Log:
  Revert r344389 & r343906 - Fix Coverity errors in newsyslog
  
  It was pointed out that a couple of the "memory leak" CIDs that I
  fixed were arguably Coverity errors rather than errors in the
  newsyslog code and the cure was worse than the disease. Revert both
  changes. The first change, which included fixes for other Coverity
  errors, will be re-worked to omit the troublesome changes and then
  re-committed with the remaining fixes.
  
  Reported by:	bde
  Sponsored by:	Dell EMC Isilon

Modified:
  head/usr.sbin/newsyslog/newsyslog.c

Modified: head/usr.sbin/newsyslog/newsyslog.c
==============================================================================
--- head/usr.sbin/newsyslog/newsyslog.c	Fri Feb 22 12:27:25 2019	(r344467)
+++ head/usr.sbin/newsyslog/newsyslog.c	Fri Feb 22 14:59:40 2019	(r344468)
@@ -253,7 +253,7 @@ static const char *path_syslogpid = _PATH_SYSLOGPID;
 
 static struct cflist *get_worklist(char **files);
 static void parse_file(FILE *cf, struct cflist *work_p, struct cflist *glob_p,
-		    struct conf_entry **defconf, struct ilist *inclist);
+		    struct conf_entry *defconf_p, struct ilist *inclist);
 static void add_to_queue(const char *fname, struct ilist *inclist);
 static char *sob(char *p);
 static char *son(char *p);
@@ -374,8 +374,6 @@ main(int argc, char **argv)
 
 	while (wait(NULL) > 0 || errno == EINTR)
 		;
-	free(timefnamefmt);
-	free(requestor);
 	return (0);
 }
 
@@ -793,9 +791,6 @@ usage(void)
 	fprintf(stderr,
 	    "usage: newsyslog [-CFNPnrsv] [-a directory] [-d directory] [-f config_file]\n"
 	    "                 [-S pidfile] [-t timefmt] [[-R tagname] file ...]\n");
-	/* Free global dynamically-allocated storage. */
-	free(timefnamefmt);
-	free(requestor);
 	exit(1);
 }
 
@@ -846,7 +841,7 @@ get_worklist(char **files)
 
 		if (verbose)
 			printf("Processing %s\n", inc->file);
-		parse_file(f, filelist, globlist, &defconf, &inclist);
+		parse_file(f, filelist, globlist, defconf, &inclist);
 		(void) fclose(f);
 	}
 
@@ -863,6 +858,7 @@ get_worklist(char **files)
 		if (defconf != NULL)
 			free_entry(defconf);
 		return (filelist);
+		/* NOTREACHED */
 	}
 
 	/*
@@ -919,7 +915,7 @@ get_worklist(char **files)
 		 * for a "glob" entry which does match.
 		 */
 		gmatch = 0;
-		if (verbose > 2)
+		if (verbose > 2 && globlist != NULL)
 			printf("\t+ Checking globs for %s\n", *given);
 		STAILQ_FOREACH(ent, globlist, cf_nextp) {
 			fnres = fnmatch(ent->log, *given, FNM_PATHNAME);
@@ -1050,7 +1046,7 @@ expand_globs(struct cflist *work_p, struct cflist *glo
  */
 static void
 parse_file(FILE *cf, struct cflist *work_p, struct cflist *glob_p,
-    struct conf_entry **defconf_p, struct ilist *inclist)
+    struct conf_entry *defconf_p, struct ilist *inclist)
 {
 	char line[BUFSIZ], *parse, *q;
 	char *cp, *errline, *group;
@@ -1141,12 +1137,12 @@ parse_file(FILE *cf, struct cflist *work_p, struct cfl
 		working = init_entry(q, NULL);
 		if (strcasecmp(DEFAULT_MARKER, q) == 0) {
 			special = 1;
-			if (*defconf_p != NULL) {
+			if (defconf_p != NULL) {
 				warnx("Ignoring duplicate entry for %s!", q);
 				free_entry(working);
 				continue;
 			}
-			*defconf_p = working;
+			defconf_p = working;
 		}
 
 		q = parse = missing_field(sob(parse + 1), errline);
@@ -1361,8 +1357,7 @@ no_trimat:
 			q = NULL;
 		else {
 			q = parse = sob(parse + 1);	/* Optional field */
-			parse = son(parse);
-			*parse = '\0';
+			*(parse = son(parse)) = '\0';
 		}
 
 		working->sig = SIGHUP;
@@ -2015,6 +2010,7 @@ do_zipwork(struct zipwork_entry *zwork)
 	const char **args, *pgm_name, *pgm_path;
 	char *zresult;
 
+	command = NULL;
 	assert(zwork != NULL);
 	assert(zwork->zw_conf != NULL);
 	assert(zwork->zw_conf->compress > COMPRESS_NONE);
@@ -2118,7 +2114,8 @@ do_zipwork(struct zipwork_entry *zwork)
 	change_attrs(zresult, zwork->zw_conf);
 
 out:
-	sbuf_delete(command);
+	if (command != NULL)
+		sbuf_delete(command);
 	free(args);
 	free(zresult);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902221459.x1MExegD026299>