Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Make sure that we initialize all accounting bytes.



details:   https://anonhg.NetBSD.org/src/rev/007a2f56c86c
branches:  trunk
changeset: 769212:007a2f56c86c
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 03 14:09:03 2011 +0000

description:
Make sure that we initialize all accounting bytes.

diffstat:

 sys/kern/kern_acct.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r e04f1488e200 -r 007a2f56c86c sys/kern/kern_acct.c
--- a/sys/kern/kern_acct.c      Sat Sep 03 13:24:19 2011 +0000
+++ b/sys/kern/kern_acct.c      Sat Sep 03 14:09:03 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_acct.c,v 1.92 2011/05/01 01:15:18 rmind Exp $     */
+/*     $NetBSD: kern_acct.c,v 1.93 2011/09/03 14:09:03 christos Exp $  */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.92 2011/05/01 01:15:18 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_acct.c,v 1.93 2011/09/03 14:09:03 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -411,6 +411,8 @@
        if (acct_state != ACCT_ACTIVE)
                return 0;
 
+       memset(&acct, 0, sizeof(acct)); /* to zerofill padded data */
+
        rw_enter(&acct_lock, RW_READER);
 
        /* If accounting isn't enabled, don't bother */
@@ -434,7 +436,7 @@
         */
 
        /* (1) The name of the command that ran */
-       memcpy(acct.ac_comm, p->p_comm, sizeof(acct.ac_comm));
+       strncpy(acct.ac_comm, p->p_comm, sizeof(acct.ac_comm));
 
        /* (2) The amount of user and system time that was used */
        mutex_enter(p->p_lock);



Home | Main Index | Thread Index | Old Index