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); _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"