From owner-p4-projects@FreeBSD.ORG Mon Aug 11 22:31:51 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1811D106567F; Mon, 11 Aug 2008 22:31:51 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CEC931065678 for ; Mon, 11 Aug 2008 22:31:50 +0000 (UTC) (envelope-from sson@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id BCA038FC16 for ; Mon, 11 Aug 2008 22:31:50 +0000 (UTC) (envelope-from sson@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7BMVo7R092491 for ; Mon, 11 Aug 2008 22:31:50 GMT (envelope-from sson@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7BMVopx092489 for perforce@freebsd.org; Mon, 11 Aug 2008 22:31:50 GMT (envelope-from sson@FreeBSD.org) Date: Mon, 11 Aug 2008 22:31:50 GMT Message-Id: <200808112231.m7BMVopx092489@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sson@FreeBSD.org using -f From: Stacey Son To: Perforce Change Reviews Cc: Subject: PERFORCE change 147187 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Aug 2008 22:31:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=147187 Change 147187 by sson@sson_amd64 on 2008/08/11 22:31:01 More strcpy() -> strncpy() and strcat() -> strncat() changes. Affected files ... .. //depot/projects/trustedbsd/openbsm/NEWS#5 edit .. //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#33 edit .. //depot/projects/trustedbsd/openbsm/bin/auditreduce/auditreduce.c#25 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/NEWS#5 (text+ko) ==== @@ -12,7 +12,7 @@ versions of the system includes in a kernel source tree, and will use the OpenBSM build infrastructure with an unmodified OpenBSM distribution, allowing the customized system includes to be used with the OpenBSM build. - Submitted by stacey Son. + Submitted by Stacey Son. OpenBSM 1.1 alpha 1 @@ -337,4 +337,4 @@ to support reloading of kernel event table. - Allow comments in /etc/security configuration files. -$P4: //depot/projects/trustedbsd/openbsm/NEWS#4 $ +$P4: //depot/projects/trustedbsd/openbsm/NEWS#5 $ ==== //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#33 (text+ko) ==== @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#32 $ + * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#33 $ */ #include @@ -152,16 +152,20 @@ char *fn; char *curdir; const char *sep = "/"; + size_t len; curdir = dirent->dirname; syslog(LOG_DEBUG, "dir = %s", dirent->dirname); - fn = malloc(strlen(curdir) + strlen(sep) + (2 * POSTFIX_LEN) + 1); + len = strlen(curdir) + strlen(sep) + (2 * POSTFIX_LEN) + 1; + fn = malloc(len); if (fn == NULL) return (NULL); - strcpy(fn, curdir); - strcat(fn, sep); - strcat(fn, name); + strncpy(fn, curdir, len); + len -= strlen(curdir); + strncat(fn, sep, len); + len -= strlen(sep); + strncat(fn, name, len); return (fn); } @@ -173,17 +177,19 @@ { char *ptr; char *oldname; + size_t len; if (lastfile != NULL) { - oldname = (char *)malloc(strlen(lastfile) + 1); + len = strlen(lastfile) + 1; + oldname = (char *)malloc(len); if (oldname == NULL) return (-1); - strcpy(oldname, lastfile); + strncpy(oldname, lastfile, len); /* Rename the last file -- append timestamp. */ if ((ptr = strstr(lastfile, NOT_TERMINATED)) != NULL) { *ptr = '.'; - strcpy(ptr+1, TS); + strncpy(ptr+1, TS, POSTFIX_LEN); if (rename(oldname, lastfile) != 0) syslog(LOG_ERR, "Could not rename %s to %s: %m", oldname, @@ -249,8 +255,8 @@ if (getTSstr(TS, POSTFIX_LEN) != 0) return (-1); - strcpy(timestr, TS); - strcat(timestr, NOT_TERMINATED); + strncpy(timestr, TS, POSTFIX_LEN); + strncat(timestr, NOT_TERMINATED, POSTFIX_LEN); #ifdef AUDIT_REVIEW_GROUP /* @@ -355,7 +361,7 @@ free(dirent); return (-1); } - strcpy(dirent->dirname, cur_dir); + strncpy(dirent->dirname, cur_dir, MAXNAMLEN); TAILQ_INSERT_TAIL(&dir_q, dirent, dirs); } ==== //depot/projects/trustedbsd/openbsm/bin/auditreduce/auditreduce.c#25 (text+ko) ==== @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/openbsm/bin/auditreduce/auditreduce.c#24 $ + * $P4: //depot/projects/trustedbsd/openbsm/bin/auditreduce/auditreduce.c#25 $ */ /* @@ -111,7 +111,7 @@ for (nstrs = 0, i = 0; i < len; i++) { if (copy[i] == ',' && i > 0) { if (copy[i - 1] == '\\') - strcpy(©[i - 1], ©[i]); + strncpy(©[i - 1], ©[i], len); else { nstrs++; copy[i] = '\0';