From owner-svn-src-head@FreeBSD.ORG Wed May 21 17:38:57 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 569E6FBD; Wed, 21 May 2014 17:38:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4489B2D50; Wed, 21 May 2014 17:38:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4LHcvql021396; Wed, 21 May 2014 17:38:57 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4LHcv3u021395; Wed, 21 May 2014 17:38:57 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201405211738.s4LHcv3u021395@svn.freebsd.org> From: Marcel Moolenaar Date: Wed, 21 May 2014 17:38:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266513 - head/usr.bin/mkimg X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 May 2014 17:38:57 -0000 Author: marcel Date: Wed May 21 17:38:56 2014 New Revision: 266513 URL: http://svnweb.freebsd.org/changeset/base/266513 Log: Fix CID 1204394: Use strncpy(3) instead of strcpy(3). Note that it's ok to not have the name and type strings terminated. Modified: head/usr.bin/mkimg/apm.c Modified: head/usr.bin/mkimg/apm.c ============================================================================== --- head/usr.bin/mkimg/apm.c Wed May 21 17:38:14 2014 (r266512) +++ head/usr.bin/mkimg/apm.c Wed May 21 17:38:56 2014 (r266513) @@ -86,8 +86,8 @@ apm_write(lba_t imgsz, void *bootcode __ be32enc(&ent->ent_pmblkcnt, nparts + 1); be32enc(&ent->ent_start, 1); be32enc(&ent->ent_size, nparts + 1); - strcpy(ent->ent_type, APM_ENT_TYPE_SELF); - strcpy(ent->ent_name, "Apple"); + strncpy(ent->ent_type, APM_ENT_TYPE_SELF, sizeof(ent->ent_type)); + strncpy(ent->ent_name, "Apple", sizeof(ent->ent_name)); STAILQ_FOREACH(part, &partlist, link) { ent = (void *)(buf + (part->index + 2) * secsz); @@ -95,9 +95,11 @@ apm_write(lba_t imgsz, void *bootcode __ be32enc(&ent->ent_pmblkcnt, nparts + 1); be32enc(&ent->ent_start, part->block); be32enc(&ent->ent_size, part->size); - strcpy(ent->ent_type, ALIAS_TYPE2PTR(part->type)); + strncpy(ent->ent_type, ALIAS_TYPE2PTR(part->type), + sizeof(ent->ent_type)); if (part->label != NULL) - strcpy(ent->ent_name, part->label); + strncpy(ent->ent_name, part->label, + sizeof(ent->ent_name)); } error = image_write(0, buf, nparts + 2);