svn commit: r359692 - stable/12/usr.sbin/newsyslog
Mark Johnston
markj at FreeBSD.org
Tue Apr 7 16:15:35 UTC 2020
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);
}
}
More information about the svn-src-stable
mailing list