Date: Tue, 7 Apr 2020 16:15:35 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r359692 - stable/12/usr.sbin/newsyslog Message-ID: <202004071615.037GFZHi035401@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Tue Apr 7 16:15:35 2020 New Revision: 359692 URL: https://svnweb.freebsd.org/changeset/base/359692 Log: MFC r359276: newsyslog: Fix stack corruption when initializing a zipwork structure. Modified: stable/12/usr.sbin/newsyslog/newsyslog.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/newsyslog/newsyslog.c ============================================================================== --- stable/12/usr.sbin/newsyslog/newsyslog.c Tue Apr 7 15:32:08 2020 (r359691) +++ stable/12/usr.sbin/newsyslog/newsyslog.c Tue Apr 7 16:15:35 2020 (r359692) @@ -1829,17 +1829,23 @@ do_rotate(const struct conf_entry *ent) else { /* XXX - Ought to be checking for failure! */ (void)rename(zfile1, zfile2); - change_attrs(zfile2, ent); - if (ent->compress && !strlen(logfile_suffix)) { - /* compress old rotation */ - struct zipwork_entry zwork; + } + change_attrs(zfile2, ent); + if (ent->compress && strlen(logfile_suffix) == 0) { + /* compress old rotation */ + struct zipwork_entry *zwork; + size_t sz; - memset(&zwork, 0, sizeof(zwork)); - zwork.zw_conf = ent; - zwork.zw_fsize = sizefile(zfile2); - strcpy(zwork.zw_fname, zfile2); - do_zipwork(&zwork); - } + sz = sizeof(*zwork) + strlen(zfile2) + 1; + zwork = calloc(1, sz); + if (zwork == NULL) + err(1, "calloc"); + + zwork->zw_conf = ent; + zwork->zw_fsize = sizefile(zfile2); + strcpy(zwork->zw_fname, zfile2); + do_zipwork(zwork); + free(zwork); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004071615.037GFZHi035401>