From owner-svn-src-all@freebsd.org Fri Feb 22 14:59:41 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEA9E14EE9B5; Fri, 22 Feb 2019 14:59:40 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 863D26FEBB; Fri, 22 Feb 2019 14:59:40 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 797746DF6; Fri, 22 Feb 2019 14:59:40 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x1MExemk026300; Fri, 22 Feb 2019 14:59:40 GMT (envelope-from dab@FreeBSD.org) Received: (from dab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1MExegD026299; Fri, 22 Feb 2019 14:59:40 GMT (envelope-from dab@FreeBSD.org) Message-Id: <201902221459.x1MExegD026299@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dab set sender to dab@FreeBSD.org using -f From: David Bright Date: Fri, 22 Feb 2019 14:59:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r344468 - head/usr.sbin/newsyslog X-SVN-Group: head X-SVN-Commit-Author: dab X-SVN-Commit-Paths: head/usr.sbin/newsyslog X-SVN-Commit-Revision: 344468 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 863D26FEBB X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Feb 2019 14:59:41 -0000 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); }