ia64/xen-unstable

changeset 13690:d2784d93e760

ia64 and ppc: Remove uses of strcpy and strncpy.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author kfraser@localhost.localdomain
date Mon Jan 29 15:01:33 2007 +0000 (2007-01-29)
parents bef7fbe25a9f
children 647c06ba0b49
files xen/arch/ia64/linux-xen/setup.c xen/arch/ia64/xen/dom_fw.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/gdbstub.c xen/arch/ia64/xen/oprofile/perfmon.c xen/arch/powerpc/domain_build.c xen/arch/powerpc/of-devtree.c xen/arch/powerpc/ofd_fixup.c
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/setup.c	Mon Jan 29 14:59:42 2007 +0000
     1.2 +++ b/xen/arch/ia64/linux-xen/setup.c	Mon Jan 29 15:01:33 2007 +0000
     1.3 @@ -424,8 +424,7 @@ setup_arch (char **cmdline_p)
     1.4  			else
     1.5  				len = strlen (mvec_name);
     1.6  			len = min(len, sizeof (str) - 1);
     1.7 -			strncpy (str, mvec_name, len);
     1.8 -			str[len] = '\0';
     1.9 +			strlcpy (str, mvec_name, len);
    1.10  			mvec_name = str;
    1.11  		} else
    1.12  			mvec_name = acpi_get_sysname();
    1.13 @@ -564,7 +563,7 @@ show_cpuinfo (struct seq_file *m, void *
    1.14  				*cp++ = sep;
    1.15  			sep = ',';
    1.16  			*cp++ = ' ';
    1.17 -			strcpy(cp, feature_bits[i].feature_name);
    1.18 +			strlcpy(cp, feature_bits[i].feature_name, sizeof(features));
    1.19  			cp += strlen(feature_bits[i].feature_name);
    1.20  			mask &= ~feature_bits[i].mask;
    1.21  		}
     2.1 --- a/xen/arch/ia64/xen/dom_fw.c	Mon Jan 29 14:59:42 2007 +0000
     2.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Mon Jan 29 15:01:33 2007 +0000
     2.3 @@ -333,13 +333,13 @@ dom_fw_fake_acpi(struct domain *d, struc
     2.4  	memset(tables, 0, sizeof(struct fake_acpi_tables));
     2.5  
     2.6  	/* setup XSDT (64bit version of RSDT) */
     2.7 -	strncpy(xsdt->signature, XSDT_SIG, 4);
     2.8 +	strlcpy(xsdt->signature, XSDT_SIG, sizeof(xsdt->signature));
     2.9  	/* XSDT points to both the FADT and the MADT, so add one entry */
    2.10  	xsdt->length = sizeof(struct xsdt_descriptor_rev2) + sizeof(u64);
    2.11  	xsdt->revision = 1;
    2.12 -	strcpy(xsdt->oem_id, "XEN");
    2.13 -	strcpy(xsdt->oem_table_id, "Xen/ia64");
    2.14 -	strcpy(xsdt->asl_compiler_id, "XEN");
    2.15 +	strlcpy(xsdt->oem_id, "XEN", sizeof(xsdt->oem_id));
    2.16 +	strlcpy(xsdt->oem_table_id, "Xen/ia64", sizeof(xsdt->oem_table_id));
    2.17 +	strlcpy(xsdt->asl_compiler_id, "XEN", sizeof(xsdt->asl_compiler_id));
    2.18  	xsdt->asl_compiler_revision = (xen_major_version() << 16) |
    2.19  		xen_minor_version();
    2.20  
    2.21 @@ -349,16 +349,16 @@ dom_fw_fake_acpi(struct domain *d, struc
    2.22  	xsdt->checksum = generate_acpi_checksum(xsdt, xsdt->length);
    2.23  
    2.24  	/* setup FADT */
    2.25 -	strncpy(fadt->signature, FADT_SIG, 4);
    2.26 +	strlcpy(fadt->signature, FADT_SIG, sizeof(fadt->signature));
    2.27  	fadt->length = sizeof(struct fadt_descriptor_rev2);
    2.28  	fadt->revision = FADT2_REVISION_ID;
    2.29 -	strcpy(fadt->oem_id, "XEN");
    2.30 -	strcpy(fadt->oem_table_id, "Xen/ia64");
    2.31 -	strcpy(fadt->asl_compiler_id, "XEN");
    2.32 +	strlcpy(fadt->oem_id, "XEN", sizeof(fadt->oem_id));
    2.33 +	strlcpy(fadt->oem_table_id, "Xen/ia64", sizeof(fadt->oem_table_id));
    2.34 +	strlcpy(fadt->asl_compiler_id, "XEN", sizeof(fadt->asl_compiler_id));
    2.35  	fadt->asl_compiler_revision = (xen_major_version() << 16) |
    2.36  		xen_minor_version();
    2.37  
    2.38 -	strncpy(facs->signature, FACS_SIG, 4);
    2.39 +	strlcpy(facs->signature, FACS_SIG, sizeof(facs->signature));
    2.40  	facs->version = 1;
    2.41  	facs->length = sizeof(struct facs_descriptor_rev2);
    2.42  
    2.43 @@ -386,8 +386,8 @@ dom_fw_fake_acpi(struct domain *d, struc
    2.44  	fadt->checksum = generate_acpi_checksum(fadt, fadt->length);
    2.45  
    2.46  	/* setup RSDP */
    2.47 -	strncpy(rsdp->signature, RSDP_SIG, 8);
    2.48 -	strcpy(rsdp->oem_id, "XEN");
    2.49 +	strlcpy(rsdp->signature, RSDP_SIG, sizeof(rsdp->signature));
    2.50 +	strlcpy(rsdp->oem_id, "XEN", sizeof(rsdp->oem_id));
    2.51  	rsdp->revision = 2; /* ACPI 2.0 includes XSDT */
    2.52  	rsdp->length = sizeof(struct acpi20_table_rsdp);
    2.53  	rsdp->xsdt_address = ACPI_TABLE_MPA(xsdt);
    2.54 @@ -397,11 +397,11 @@ dom_fw_fake_acpi(struct domain *d, struc
    2.55  	rsdp->ext_checksum = generate_acpi_checksum(rsdp, rsdp->length);
    2.56  
    2.57  	/* setup DSDT with trivial namespace. */ 
    2.58 -	strncpy(dsdt->signature, DSDT_SIG, 4);
    2.59 +	strlcpy(dsdt->signature, DSDT_SIG, sizeof(dsdt->signature));
    2.60  	dsdt->revision = 1;
    2.61 -	strcpy(dsdt->oem_id, "XEN");
    2.62 -	strcpy(dsdt->oem_table_id, "Xen/ia64");
    2.63 -	strcpy(dsdt->asl_compiler_id, "XEN");
    2.64 +	strlcpy(dsdt->oem_id, "XEN", sizeof(dsdt->oem_id));
    2.65 +	strlcpy(dsdt->oem_table_id, "Xen/ia64", sizeof(dsdt->oem_table_id));
    2.66 +	strlcpy(dsdt->asl_compiler_id, "XEN", sizeof(dsdt->asl_compiler_id));
    2.67  	dsdt->asl_compiler_revision = (xen_major_version() << 16) |
    2.68  		xen_minor_version();
    2.69  
    2.70 @@ -409,7 +409,7 @@ dom_fw_fake_acpi(struct domain *d, struc
    2.71  	tables->aml[0] = 0x10; /* Scope */
    2.72  	tables->aml[1] = 0x40; /* length/offset to next object (patched) */
    2.73  	tables->aml[2] = 0x00;
    2.74 -	strncpy((char *)&tables->aml[3], "_SB_", 4);
    2.75 +	strlcpy((char *)&tables->aml[3], "_SB_", 5);
    2.76  
    2.77  	/* The processor object isn't absolutely necessary, revist for SMP */
    2.78  	aml_len = 7;
    2.79 @@ -437,11 +437,14 @@ dom_fw_fake_acpi(struct domain *d, struc
    2.80  	dsdt->checksum = generate_acpi_checksum(dsdt, dsdt->length);
    2.81  
    2.82  	/* setup MADT */
    2.83 -	strncpy(madt->header.signature, APIC_SIG, 4);
    2.84 +	strlcpy(madt->header.signature, APIC_SIG, sizeof(madt->header.signature));
    2.85  	madt->header.revision = 2;
    2.86 -	strcpy(madt->header.oem_id, "XEN");
    2.87 -	strcpy(madt->header.oem_table_id, "Xen/ia64");
    2.88 -	strcpy(madt->header.asl_compiler_id, "XEN");
    2.89 +	strlcpy(madt->header.oem_id, "XEN",
    2.90 +		sizeof(madt->header.oem_id));
    2.91 +	strlcpy(madt->header.oem_table_id, "Xen/ia64",
    2.92 +		sizeof(madt->header.oem_table_id));
    2.93 +	strlcpy(madt->header.asl_compiler_id, "XEN",
    2.94 +		sizeof(madt->header.asl_compiler_id));
    2.95  	madt->header.asl_compiler_revision = (xen_major_version() << 16) |
    2.96  		xen_minor_version();
    2.97  
    2.98 @@ -760,8 +763,10 @@ dom_fw_init(struct domain *d,
    2.99  	tables->sal_systab.sal_rev_major = 0;
   2.100  	tables->sal_systab.entry_count = 2;
   2.101  
   2.102 -	strcpy((char *)tables->sal_systab.oem_id, "Xen/ia64");
   2.103 -	strcpy((char *)tables->sal_systab.product_id, "Xen/ia64");
   2.104 +	strlcpy((char *)tables->sal_systab.oem_id, "Xen/ia64",
   2.105 +		sizeof(tables->sal_systab.oem_id));
   2.106 +	strlcpy((char *)tables->sal_systab.product_id, "Xen/ia64",
   2.107 +		sizeof(tables->sal_systab.product_id));
   2.108  
   2.109  	/* PAL entry point: */
   2.110  	tables->sal_ed.type = SAL_DESC_ENTRY_POINT;
     3.1 --- a/xen/arch/ia64/xen/domain.c	Mon Jan 29 14:59:42 2007 +0000
     3.2 +++ b/xen/arch/ia64/xen/domain.c	Mon Jan 29 15:01:33 2007 +0000
     3.3 @@ -1148,8 +1148,7 @@ int construct_dom0(struct domain *d,
     3.4  	dom_fw_setup(d, bp_mpa, max_pages * PAGE_SIZE);
     3.5  
     3.6  	/* Fill boot param.  */
     3.7 -	strncpy((char *)si->cmd_line, dom0_command_line, sizeof(si->cmd_line));
     3.8 -	si->cmd_line[sizeof(si->cmd_line)-1] = 0;
     3.9 +	strlcpy((char *)si->cmd_line, dom0_command_line, sizeof(si->cmd_line));
    3.10  
    3.11  	bp = (struct ia64_boot_param *)((unsigned char *)si +
    3.12  	                                sizeof(start_info_t));
     4.1 --- a/xen/arch/ia64/xen/gdbstub.c	Mon Jan 29 14:59:42 2007 +0000
     4.2 +++ b/xen/arch/ia64/xen/gdbstub.c	Mon Jan 29 15:01:33 2007 +0000
     4.3 @@ -639,7 +639,7 @@ kgdb_get_reg(int regnum, struct unw_fram
     4.4  		outbuffer[size*2] = 0;
     4.5  	}
     4.6  	else
     4.7 -		strcpy(outbuffer, "E0");
     4.8 +		strlcpy(outbuffer, "E0", sizeof("E0"));
     4.9  
    4.10  	return;
    4.11  #else
     5.1 --- a/xen/arch/ia64/xen/oprofile/perfmon.c	Mon Jan 29 14:59:42 2007 +0000
     5.2 +++ b/xen/arch/ia64/xen/oprofile/perfmon.c	Mon Jan 29 15:01:33 2007 +0000
     5.3 @@ -119,7 +119,7 @@ int
     5.4  xenoprof_arch_init(int *num_events, int *is_primary, char *cpu_type)
     5.5  {
     5.6      *num_events = 0;
     5.7 -    strncpy(cpu_type, get_cpu_type(), XENOPROF_CPU_TYPE_SIZE - 1);
     5.8 +    strlcpy(cpu_type, get_cpu_type(), XENOPROF_CPU_TYPE_SIZE);
     5.9      cpu_type[XENOPROF_CPU_TYPE_SIZE - 1] = '\0';
    5.10  
    5.11      *is_primary = 0;
     6.1 --- a/xen/arch/powerpc/domain_build.c	Mon Jan 29 14:59:42 2007 +0000
     6.2 +++ b/xen/arch/powerpc/domain_build.c	Mon Jan 29 15:01:33 2007 +0000
     6.3 @@ -290,7 +290,7 @@ int construct_dom0(struct domain *d,
     6.4  
     6.5      memset(si->cmd_line, 0, sizeof(si->cmd_line));
     6.6      if ( cmdline != NULL )
     6.7 -        strncpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line)-1);
     6.8 +        strlcpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line));
     6.9  
    6.10      v->arch.ctxt.msr = msr;
    6.11      v->arch.ctxt.pc = pc;
     7.1 --- a/xen/arch/powerpc/of-devtree.c	Mon Jan 29 14:59:42 2007 +0000
     7.2 +++ b/xen/arch/powerpc/of-devtree.c	Mon Jan 29 15:01:33 2007 +0000
     7.3 @@ -358,8 +358,7 @@ static ofdn_t ofd_node_create(
     7.4      n->on_io = 0;
     7.5      n->on_pathlen = pathlen;
     7.6      n->on_last = ofd_pathsplit_left(path, '/', pathlen);
     7.7 -    strncpy(n->on_path, path, pathlen);
     7.8 -    n->on_path[n->on_pathlen] = 0;
     7.9 +    strlcpy(n->on_path, path, pathlen);
    7.10  
    7.11      return pos;
    7.12  }
     8.1 --- a/xen/arch/powerpc/ofd_fixup.c	Mon Jan 29 14:59:42 2007 +0000
     8.2 +++ b/xen/arch/powerpc/ofd_fixup.c	Mon Jan 29 15:01:33 2007 +0000
     8.3 @@ -267,7 +267,7 @@ static ofdn_t ofd_chosen_props(void *m, 
     8.4                       &path[1], sizeof (path) - 1);
     8.5      }
     8.6  
     8.7 -    strcpy(bootargs, cmdline);
     8.8 +    strlcpy(bootargs, cmdline, sizeof(bootargs));
     8.9      bsz = strlen(bootargs) + 1;
    8.10      rm = sizeof (bootargs) - bsz;
    8.11