* Re: [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy.
[not found] <200701291502.l0TF2Md1000372@latara.uk.xensource.com>
@ 2007-01-29 23:47 ` Aron Griffis
2007-01-30 7:11 ` Christoph Egger
2007-01-29 23:53 ` Aron Griffis
1 sibling, 1 reply; 6+ messages in thread
From: Aron Griffis @ 2007-01-29 23:47 UTC (permalink / raw)
To: Christoph Egger; +Cc: xen-devel
Hi Christoph,
Was this patch floated on xen-devel and/or xen-ia64-devel? I'm having
trouble finding it, and I think I'm seeing some problems in it, see
below.
Aron
Xen staging patchbot-unstable wrote: [Mon Jan 29 2007, 10:02:21AM EST]
> # HG changeset patch
> # User kfraser@localhost.localdomain
> # Date 1170082893 0
> # Node ID d2784d93e760ad96ab25cb7cacee491177708ce0
> # Parent bef7fbe25a9f380d40623795befacd447b026837
> ia64 and ppc: Remove uses of strcpy and strncpy.
> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
> ---
> xen/arch/ia64/linux-xen/setup.c | 5 +--
> xen/arch/ia64/xen/dom_fw.c | 49 +++++++++++++++++++----------------
> xen/arch/ia64/xen/domain.c | 3 --
> xen/arch/ia64/xen/gdbstub.c | 2 -
> xen/arch/ia64/xen/oprofile/perfmon.c | 2 -
> xen/arch/powerpc/domain_build.c | 2 -
> xen/arch/powerpc/of-devtree.c | 3 --
> xen/arch/powerpc/ofd_fixup.c | 2 -
> 8 files changed, 35 insertions(+), 33 deletions(-)
>
> diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/linux-xen/setup.c
> --- a/xen/arch/ia64/linux-xen/setup.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/ia64/linux-xen/setup.c Mon Jan 29 15:01:33 2007 +0000
> @@ -424,8 +424,7 @@ setup_arch (char **cmdline_p)
> else
> len = strlen (mvec_name);
> len = min(len, sizeof (str) - 1);
> - strncpy (str, mvec_name, len);
> - str[len] = '\0';
> + strlcpy (str, mvec_name, len);
> mvec_name = str;
> } else
> mvec_name = acpi_get_sysname();
> @@ -564,7 +563,7 @@ show_cpuinfo (struct seq_file *m, void *
> *cp++ = sep;
> sep = ',';
> *cp++ = ' ';
> - strcpy(cp, feature_bits[i].feature_name);
> + strlcpy(cp, feature_bits[i].feature_name, sizeof(features));
> cp += strlen(feature_bits[i].feature_name);
> mask &= ~feature_bits[i].mask;
> }
> diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/xen/dom_fw.c
> --- a/xen/arch/ia64/xen/dom_fw.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/ia64/xen/dom_fw.c Mon Jan 29 15:01:33 2007 +0000
> @@ -333,13 +333,13 @@ dom_fw_fake_acpi(struct domain *d, struc
> memset(tables, 0, sizeof(struct fake_acpi_tables));
>
> /* setup XSDT (64bit version of RSDT) */
> - strncpy(xsdt->signature, XSDT_SIG, 4);
> + strlcpy(xsdt->signature, XSDT_SIG, sizeof(xsdt->signature));
Since xsdt->signature is 4 bytes, strncpy() worked fine and
appropriately left off the trailing NUL. Switching to strlcpy()
forces the NUL onto the end, truncating the content to 3 bytes.
> /* XSDT points to both the FADT and the MADT, so add one entry */
> xsdt->length = sizeof(struct xsdt_descriptor_rev2) + sizeof(u64);
> xsdt->revision = 1;
> - strcpy(xsdt->oem_id, "XEN");
> - strcpy(xsdt->oem_table_id, "Xen/ia64");
> - strcpy(xsdt->asl_compiler_id, "XEN");
> + strlcpy(xsdt->oem_id, "XEN", sizeof(xsdt->oem_id));
> + strlcpy(xsdt->oem_table_id, "Xen/ia64", sizeof(xsdt->oem_table_id));
> + strlcpy(xsdt->asl_compiler_id, "XEN", sizeof(xsdt->asl_compiler_id));
> xsdt->asl_compiler_revision = (xen_major_version() << 16) |
> xen_minor_version();
>
> @@ -349,16 +349,16 @@ dom_fw_fake_acpi(struct domain *d, struc
> xsdt->checksum = generate_acpi_checksum(xsdt, xsdt->length);
>
> /* setup FADT */
> - strncpy(fadt->signature, FADT_SIG, 4);
> + strlcpy(fadt->signature, FADT_SIG, sizeof(fadt->signature));
again
> fadt->length = sizeof(struct fadt_descriptor_rev2);
> fadt->revision = FADT2_REVISION_ID;
> - strcpy(fadt->oem_id, "XEN");
> - strcpy(fadt->oem_table_id, "Xen/ia64");
> - strcpy(fadt->asl_compiler_id, "XEN");
> + strlcpy(fadt->oem_id, "XEN", sizeof(fadt->oem_id));
> + strlcpy(fadt->oem_table_id, "Xen/ia64", sizeof(fadt->oem_table_id));
> + strlcpy(fadt->asl_compiler_id, "XEN", sizeof(fadt->asl_compiler_id));
> fadt->asl_compiler_revision = (xen_major_version() << 16) |
> xen_minor_version();
>
> - strncpy(facs->signature, FACS_SIG, 4);
> + strlcpy(facs->signature, FACS_SIG, sizeof(facs->signature));
again
> facs->version = 1;
> facs->length = sizeof(struct facs_descriptor_rev2);
>
> @@ -386,8 +386,8 @@ dom_fw_fake_acpi(struct domain *d, struc
> fadt->checksum = generate_acpi_checksum(fadt, fadt->length);
>
> /* setup RSDP */
> - strncpy(rsdp->signature, RSDP_SIG, 8);
> - strcpy(rsdp->oem_id, "XEN");
> + strlcpy(rsdp->signature, RSDP_SIG, sizeof(rsdp->signature));
again
> + strlcpy(rsdp->oem_id, "XEN", sizeof(rsdp->oem_id));
> rsdp->revision = 2; /* ACPI 2.0 includes XSDT */
> rsdp->length = sizeof(struct acpi20_table_rsdp);
> rsdp->xsdt_address = ACPI_TABLE_MPA(xsdt);
> @@ -397,11 +397,11 @@ dom_fw_fake_acpi(struct domain *d, struc
> rsdp->ext_checksum = generate_acpi_checksum(rsdp, rsdp->length);
>
> /* setup DSDT with trivial namespace. */
> - strncpy(dsdt->signature, DSDT_SIG, 4);
> + strlcpy(dsdt->signature, DSDT_SIG, sizeof(dsdt->signature));
again
> dsdt->revision = 1;
> - strcpy(dsdt->oem_id, "XEN");
> - strcpy(dsdt->oem_table_id, "Xen/ia64");
> - strcpy(dsdt->asl_compiler_id, "XEN");
> + strlcpy(dsdt->oem_id, "XEN", sizeof(dsdt->oem_id));
> + strlcpy(dsdt->oem_table_id, "Xen/ia64", sizeof(dsdt->oem_table_id));
> + strlcpy(dsdt->asl_compiler_id, "XEN", sizeof(dsdt->asl_compiler_id));
> dsdt->asl_compiler_revision = (xen_major_version() << 16) |
> xen_minor_version();
>
> @@ -409,7 +409,7 @@ dom_fw_fake_acpi(struct domain *d, struc
> tables->aml[0] = 0x10; /* Scope */
> tables->aml[1] = 0x40; /* length/offset to next object (patched) */
> tables->aml[2] = 0x00;
> - strncpy((char *)&tables->aml[3], "_SB_", 4);
> + strlcpy((char *)&tables->aml[3], "_SB_", 5);
again
> /* The processor object isn't absolutely necessary, revist for SMP */
> aml_len = 7;
> @@ -437,11 +437,14 @@ dom_fw_fake_acpi(struct domain *d, struc
> dsdt->checksum = generate_acpi_checksum(dsdt, dsdt->length);
>
> /* setup MADT */
> - strncpy(madt->header.signature, APIC_SIG, 4);
> + strlcpy(madt->header.signature, APIC_SIG, sizeof(madt->header.signature));
again
> madt->header.revision = 2;
> - strcpy(madt->header.oem_id, "XEN");
> - strcpy(madt->header.oem_table_id, "Xen/ia64");
> - strcpy(madt->header.asl_compiler_id, "XEN");
> + strlcpy(madt->header.oem_id, "XEN",
> + sizeof(madt->header.oem_id));
> + strlcpy(madt->header.oem_table_id, "Xen/ia64",
> + sizeof(madt->header.oem_table_id));
> + strlcpy(madt->header.asl_compiler_id, "XEN",
> + sizeof(madt->header.asl_compiler_id));
> madt->header.asl_compiler_revision = (xen_major_version() << 16) |
> xen_minor_version();
>
> @@ -760,8 +763,10 @@ dom_fw_init(struct domain *d,
> tables->sal_systab.sal_rev_major = 0;
> tables->sal_systab.entry_count = 2;
>
> - strcpy((char *)tables->sal_systab.oem_id, "Xen/ia64");
> - strcpy((char *)tables->sal_systab.product_id, "Xen/ia64");
> + strlcpy((char *)tables->sal_systab.oem_id, "Xen/ia64",
> + sizeof(tables->sal_systab.oem_id));
> + strlcpy((char *)tables->sal_systab.product_id, "Xen/ia64",
> + sizeof(tables->sal_systab.product_id));
>
> /* PAL entry point: */
> tables->sal_ed.type = SAL_DESC_ENTRY_POINT;
> diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/xen/domain.c
> --- a/xen/arch/ia64/xen/domain.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/ia64/xen/domain.c Mon Jan 29 15:01:33 2007 +0000
> @@ -1148,8 +1148,7 @@ int construct_dom0(struct domain *d,
> dom_fw_setup(d, bp_mpa, max_pages * PAGE_SIZE);
>
> /* Fill boot param. */
> - strncpy((char *)si->cmd_line, dom0_command_line, sizeof(si->cmd_line));
> - si->cmd_line[sizeof(si->cmd_line)-1] = 0;
> + strlcpy((char *)si->cmd_line, dom0_command_line, sizeof(si->cmd_line));
>
> bp = (struct ia64_boot_param *)((unsigned char *)si +
> sizeof(start_info_t));
> diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/xen/gdbstub.c
> --- a/xen/arch/ia64/xen/gdbstub.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/ia64/xen/gdbstub.c Mon Jan 29 15:01:33 2007 +0000
> @@ -639,7 +639,7 @@ kgdb_get_reg(int regnum, struct unw_fram
> outbuffer[size*2] = 0;
> }
> else
> - strcpy(outbuffer, "E0");
> + strlcpy(outbuffer, "E0", sizeof("E0"));
>
> return;
> #else
> diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/xen/oprofile/perfmon.c
> --- a/xen/arch/ia64/xen/oprofile/perfmon.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/ia64/xen/oprofile/perfmon.c Mon Jan 29 15:01:33 2007 +0000
> @@ -119,7 +119,7 @@ xenoprof_arch_init(int *num_events, int
> xenoprof_arch_init(int *num_events, int *is_primary, char *cpu_type)
> {
> *num_events = 0;
> - strncpy(cpu_type, get_cpu_type(), XENOPROF_CPU_TYPE_SIZE - 1);
> + strlcpy(cpu_type, get_cpu_type(), XENOPROF_CPU_TYPE_SIZE);
> cpu_type[XENOPROF_CPU_TYPE_SIZE - 1] = '\0';
This extra NUL is not needed with strlcpy
> *is_primary = 0;
> diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/powerpc/domain_build.c
> --- a/xen/arch/powerpc/domain_build.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/powerpc/domain_build.c Mon Jan 29 15:01:33 2007 +0000
> @@ -290,7 +290,7 @@ int construct_dom0(struct domain *d,
>
> memset(si->cmd_line, 0, sizeof(si->cmd_line));
> if ( cmdline != NULL )
> - strncpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line)-1);
> + strlcpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line));
>
> v->arch.ctxt.msr = msr;
> v->arch.ctxt.pc = pc;
> diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/powerpc/of-devtree.c
> --- a/xen/arch/powerpc/of-devtree.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/powerpc/of-devtree.c Mon Jan 29 15:01:33 2007 +0000
> @@ -358,8 +358,7 @@ static ofdn_t ofd_node_create(
> n->on_io = 0;
> n->on_pathlen = pathlen;
> n->on_last = ofd_pathsplit_left(path, '/', pathlen);
> - strncpy(n->on_path, path, pathlen);
> - n->on_path[n->on_pathlen] = 0;
> + strlcpy(n->on_path, path, pathlen);
>
> return pos;
> }
> diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/powerpc/ofd_fixup.c
> --- a/xen/arch/powerpc/ofd_fixup.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/powerpc/ofd_fixup.c Mon Jan 29 15:01:33 2007 +0000
> @@ -267,7 +267,7 @@ static ofdn_t ofd_chosen_props(void *m,
> &path[1], sizeof (path) - 1);
> }
>
> - strcpy(bootargs, cmdline);
> + strlcpy(bootargs, cmdline, sizeof(bootargs));
> bsz = strlen(bootargs) + 1;
> rm = sizeof (bootargs) - bsz;
>
>
> _______________________________________________
> Xen-staging mailing list
> Xen-staging@lists.xensource.com
> http://lists.xensource.com/xen-staging
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy.
[not found] <200701291502.l0TF2Md1000372@latara.uk.xensource.com>
2007-01-29 23:47 ` [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy Aron Griffis
@ 2007-01-29 23:53 ` Aron Griffis
2007-01-30 0:06 ` Aron Griffis
1 sibling, 1 reply; 6+ messages in thread
From: Aron Griffis @ 2007-01-29 23:53 UTC (permalink / raw)
To: xen-devel
Additionally...
Xen staging patchbot-unstable wrote: [Mon Jan 29 2007, 10:02:21AM EST]
> --- a/xen/arch/ia64/xen/gdbstub.c Mon Jan 29 14:59:42 2007 +0000
> +++ b/xen/arch/ia64/xen/gdbstub.c Mon Jan 29 15:01:33 2007 +0000
> @@ -639,7 +639,7 @@ kgdb_get_reg(int regnum, struct unw_fram
> outbuffer[size*2] = 0;
> }
> else
> - strcpy(outbuffer, "E0");
> + strlcpy(outbuffer, "E0", sizeof("E0"));
Better to use safe_strcpy here instead of duplicating
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Re: [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy.
2007-01-29 23:53 ` Aron Griffis
@ 2007-01-30 0:06 ` Aron Griffis
0 siblings, 0 replies; 6+ messages in thread
From: Aron Griffis @ 2007-01-30 0:06 UTC (permalink / raw)
To: xen-devel
Aron Griffis wrote: [Mon Jan 29 2007, 06:53:57PM EST]
> Additionally...
>
> Xen staging patchbot-unstable wrote: [Mon Jan 29 2007, 10:02:21AM EST]
> > --- a/xen/arch/ia64/xen/gdbstub.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/ia64/xen/gdbstub.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -639,7 +639,7 @@ kgdb_get_reg(int regnum, struct unw_fram
> > outbuffer[size*2] = 0;
> > }
> > else
> > - strcpy(outbuffer, "E0");
> > + strlcpy(outbuffer, "E0", sizeof("E0"));
>
> Better to use safe_strcpy here instead of duplicating
My mistake here. safe_strcpy uses sizeof(dst) not sizeof(src). Your
change seems like the best choice in the absence of strcpy()
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy.
2007-01-29 23:47 ` [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy Aron Griffis
@ 2007-01-30 7:11 ` Christoph Egger
2007-01-30 13:25 ` Alex Williamson
2007-01-30 13:50 ` Aron Griffis
0 siblings, 2 replies; 6+ messages in thread
From: Christoph Egger @ 2007-01-30 7:11 UTC (permalink / raw)
To: xen-devel; +Cc: Aron Griffis
On Tuesday 30 January 2007 00:47, Aron Griffis wrote:
> Hi Christoph,
>
> Was this patch floated on xen-devel and/or xen-ia64-devel? I'm having
> trouble finding it, and I think I'm seeing some problems in it, see
> below.
I posted it to xen-devel. I'm not subscribed on ia64-devel.
According to the troubles you pointed out indicates, that the
ACPI header fields need one more byte for the NUL.
>
> Aron
>
> Xen staging patchbot-unstable wrote: [Mon Jan 29 2007, 10:02:21AM EST]
>
> > # HG changeset patch
> > # User kfraser@localhost.localdomain
> > # Date 1170082893 0
> > # Node ID d2784d93e760ad96ab25cb7cacee491177708ce0
> > # Parent bef7fbe25a9f380d40623795befacd447b026837
> > ia64 and ppc: Remove uses of strcpy and strncpy.
> > Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
> > ---
> > xen/arch/ia64/linux-xen/setup.c | 5 +--
> > xen/arch/ia64/xen/dom_fw.c | 49
> > +++++++++++++++++++---------------- xen/arch/ia64/xen/domain.c
> > | 3 --
> > xen/arch/ia64/xen/gdbstub.c | 2 -
> > xen/arch/ia64/xen/oprofile/perfmon.c | 2 -
> > xen/arch/powerpc/domain_build.c | 2 -
> > xen/arch/powerpc/of-devtree.c | 3 --
> > xen/arch/powerpc/ofd_fixup.c | 2 -
> > 8 files changed, 35 insertions(+), 33 deletions(-)
> >
> > diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/linux-xen/setup.c
> > --- a/xen/arch/ia64/linux-xen/setup.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/ia64/linux-xen/setup.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -424,8 +424,7 @@ setup_arch (char **cmdline_p)
> > else
> > len = strlen (mvec_name);
> > len = min(len, sizeof (str) - 1);
> > - strncpy (str, mvec_name, len);
> > - str[len] = '\0';
> > + strlcpy (str, mvec_name, len);
> > mvec_name = str;
> > } else
> > mvec_name = acpi_get_sysname();
> > @@ -564,7 +563,7 @@ show_cpuinfo (struct seq_file *m, void *
> > *cp++ = sep;
> > sep = ',';
> > *cp++ = ' ';
> > - strcpy(cp, feature_bits[i].feature_name);
> > + strlcpy(cp, feature_bits[i].feature_name, sizeof(features));
> > cp += strlen(feature_bits[i].feature_name);
> > mask &= ~feature_bits[i].mask;
> > }
> > diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/xen/dom_fw.c
> > --- a/xen/arch/ia64/xen/dom_fw.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/ia64/xen/dom_fw.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -333,13 +333,13 @@ dom_fw_fake_acpi(struct domain *d, struc
> > memset(tables, 0, sizeof(struct fake_acpi_tables));
> >
> > /* setup XSDT (64bit version of RSDT) */
> > - strncpy(xsdt->signature, XSDT_SIG, 4);
> > + strlcpy(xsdt->signature, XSDT_SIG, sizeof(xsdt->signature));
>
> Since xsdt->signature is 4 bytes, strncpy() worked fine and
> appropriately left off the trailing NUL. Switching to strlcpy()
> forces the NUL onto the end, truncating the content to 3 bytes.
>
> > /* XSDT points to both the FADT and the MADT, so add one entry */
> > xsdt->length = sizeof(struct xsdt_descriptor_rev2) + sizeof(u64);
> > xsdt->revision = 1;
> > - strcpy(xsdt->oem_id, "XEN");
> > - strcpy(xsdt->oem_table_id, "Xen/ia64");
> > - strcpy(xsdt->asl_compiler_id, "XEN");
> > + strlcpy(xsdt->oem_id, "XEN", sizeof(xsdt->oem_id));
> > + strlcpy(xsdt->oem_table_id, "Xen/ia64", sizeof(xsdt->oem_table_id));
> > + strlcpy(xsdt->asl_compiler_id, "XEN", sizeof(xsdt->asl_compiler_id));
> > xsdt->asl_compiler_revision = (xen_major_version() << 16) |
> > xen_minor_version();
> >
> > @@ -349,16 +349,16 @@ dom_fw_fake_acpi(struct domain *d, struc
> > xsdt->checksum = generate_acpi_checksum(xsdt, xsdt->length);
> >
> > /* setup FADT */
> > - strncpy(fadt->signature, FADT_SIG, 4);
> > + strlcpy(fadt->signature, FADT_SIG, sizeof(fadt->signature));
>
> again
>
> > fadt->length = sizeof(struct fadt_descriptor_rev2);
> > fadt->revision = FADT2_REVISION_ID;
> > - strcpy(fadt->oem_id, "XEN");
> > - strcpy(fadt->oem_table_id, "Xen/ia64");
> > - strcpy(fadt->asl_compiler_id, "XEN");
> > + strlcpy(fadt->oem_id, "XEN", sizeof(fadt->oem_id));
> > + strlcpy(fadt->oem_table_id, "Xen/ia64", sizeof(fadt->oem_table_id));
> > + strlcpy(fadt->asl_compiler_id, "XEN", sizeof(fadt->asl_compiler_id));
> > fadt->asl_compiler_revision = (xen_major_version() << 16) |
> > xen_minor_version();
> >
> > - strncpy(facs->signature, FACS_SIG, 4);
> > + strlcpy(facs->signature, FACS_SIG, sizeof(facs->signature));
>
> again
>
> > facs->version = 1;
> > facs->length = sizeof(struct facs_descriptor_rev2);
> >
> > @@ -386,8 +386,8 @@ dom_fw_fake_acpi(struct domain *d, struc
> > fadt->checksum = generate_acpi_checksum(fadt, fadt->length);
> >
> > /* setup RSDP */
> > - strncpy(rsdp->signature, RSDP_SIG, 8);
> > - strcpy(rsdp->oem_id, "XEN");
> > + strlcpy(rsdp->signature, RSDP_SIG, sizeof(rsdp->signature));
>
> again
>
> > + strlcpy(rsdp->oem_id, "XEN", sizeof(rsdp->oem_id));
> > rsdp->revision = 2; /* ACPI 2.0 includes XSDT */
> > rsdp->length = sizeof(struct acpi20_table_rsdp);
> > rsdp->xsdt_address = ACPI_TABLE_MPA(xsdt);
> > @@ -397,11 +397,11 @@ dom_fw_fake_acpi(struct domain *d, struc
> > rsdp->ext_checksum = generate_acpi_checksum(rsdp, rsdp->length);
> >
> > /* setup DSDT with trivial namespace. */
> > - strncpy(dsdt->signature, DSDT_SIG, 4);
> > + strlcpy(dsdt->signature, DSDT_SIG, sizeof(dsdt->signature));
>
> again
>
> > dsdt->revision = 1;
> > - strcpy(dsdt->oem_id, "XEN");
> > - strcpy(dsdt->oem_table_id, "Xen/ia64");
> > - strcpy(dsdt->asl_compiler_id, "XEN");
> > + strlcpy(dsdt->oem_id, "XEN", sizeof(dsdt->oem_id));
> > + strlcpy(dsdt->oem_table_id, "Xen/ia64", sizeof(dsdt->oem_table_id));
> > + strlcpy(dsdt->asl_compiler_id, "XEN", sizeof(dsdt->asl_compiler_id));
> > dsdt->asl_compiler_revision = (xen_major_version() << 16) |
> > xen_minor_version();
> >
> > @@ -409,7 +409,7 @@ dom_fw_fake_acpi(struct domain *d, struc
> > tables->aml[0] = 0x10; /* Scope */
> > tables->aml[1] = 0x40; /* length/offset to next object (patched) */
> > tables->aml[2] = 0x00;
> > - strncpy((char *)&tables->aml[3], "_SB_", 4);
> > + strlcpy((char *)&tables->aml[3], "_SB_", 5);
>
> again
>
> > /* The processor object isn't absolutely necessary, revist for SMP */
> > aml_len = 7;
> > @@ -437,11 +437,14 @@ dom_fw_fake_acpi(struct domain *d, struc
> > dsdt->checksum = generate_acpi_checksum(dsdt, dsdt->length);
> >
> > /* setup MADT */
> > - strncpy(madt->header.signature, APIC_SIG, 4);
> > + strlcpy(madt->header.signature, APIC_SIG,
> > sizeof(madt->header.signature));
>
> again
>
> > madt->header.revision = 2;
> > - strcpy(madt->header.oem_id, "XEN");
> > - strcpy(madt->header.oem_table_id, "Xen/ia64");
> > - strcpy(madt->header.asl_compiler_id, "XEN");
> > + strlcpy(madt->header.oem_id, "XEN",
> > + sizeof(madt->header.oem_id));
> > + strlcpy(madt->header.oem_table_id, "Xen/ia64",
> > + sizeof(madt->header.oem_table_id));
> > + strlcpy(madt->header.asl_compiler_id, "XEN",
> > + sizeof(madt->header.asl_compiler_id));
> > madt->header.asl_compiler_revision = (xen_major_version() << 16) |
> > xen_minor_version();
> >
> > @@ -760,8 +763,10 @@ dom_fw_init(struct domain *d,
> > tables->sal_systab.sal_rev_major = 0;
> > tables->sal_systab.entry_count = 2;
> >
> > - strcpy((char *)tables->sal_systab.oem_id, "Xen/ia64");
> > - strcpy((char *)tables->sal_systab.product_id, "Xen/ia64");
> > + strlcpy((char *)tables->sal_systab.oem_id, "Xen/ia64",
> > + sizeof(tables->sal_systab.oem_id));
> > + strlcpy((char *)tables->sal_systab.product_id, "Xen/ia64",
> > + sizeof(tables->sal_systab.product_id));
> >
> > /* PAL entry point: */
> > tables->sal_ed.type = SAL_DESC_ENTRY_POINT;
> > diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/xen/domain.c
> > --- a/xen/arch/ia64/xen/domain.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/ia64/xen/domain.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -1148,8 +1148,7 @@ int construct_dom0(struct domain *d,
> > dom_fw_setup(d, bp_mpa, max_pages * PAGE_SIZE);
> >
> > /* Fill boot param. */
> > - strncpy((char *)si->cmd_line, dom0_command_line, sizeof(si->cmd_line));
> > - si->cmd_line[sizeof(si->cmd_line)-1] = 0;
> > + strlcpy((char *)si->cmd_line, dom0_command_line, sizeof(si->cmd_line));
> >
> > bp = (struct ia64_boot_param *)((unsigned char *)si +
> > sizeof(start_info_t));
> > diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/xen/gdbstub.c
> > --- a/xen/arch/ia64/xen/gdbstub.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/ia64/xen/gdbstub.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -639,7 +639,7 @@ kgdb_get_reg(int regnum, struct unw_fram
> > outbuffer[size*2] = 0;
> > }
> > else
> > - strcpy(outbuffer, "E0");
> > + strlcpy(outbuffer, "E0", sizeof("E0"));
> >
> > return;
> > #else
> > diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/ia64/xen/oprofile/perfmon.c
> > --- a/xen/arch/ia64/xen/oprofile/perfmon.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/ia64/xen/oprofile/perfmon.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -119,7 +119,7 @@ xenoprof_arch_init(int *num_events, int
> > xenoprof_arch_init(int *num_events, int *is_primary, char *cpu_type)
> > {
> > *num_events = 0;
> > - strncpy(cpu_type, get_cpu_type(), XENOPROF_CPU_TYPE_SIZE - 1);
> > + strlcpy(cpu_type, get_cpu_type(), XENOPROF_CPU_TYPE_SIZE);
> > cpu_type[XENOPROF_CPU_TYPE_SIZE - 1] = '\0';
>
> This extra NUL is not needed with strlcpy
>
> > *is_primary = 0;
> > diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/powerpc/domain_build.c
> > --- a/xen/arch/powerpc/domain_build.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/powerpc/domain_build.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -290,7 +290,7 @@ int construct_dom0(struct domain *d,
> >
> > memset(si->cmd_line, 0, sizeof(si->cmd_line));
> > if ( cmdline != NULL )
> > - strncpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line)-1);
> > + strlcpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line));
> >
> > v->arch.ctxt.msr = msr;
> > v->arch.ctxt.pc = pc;
> > diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/powerpc/of-devtree.c
> > --- a/xen/arch/powerpc/of-devtree.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/powerpc/of-devtree.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -358,8 +358,7 @@ static ofdn_t ofd_node_create(
> > n->on_io = 0;
> > n->on_pathlen = pathlen;
> > n->on_last = ofd_pathsplit_left(path, '/', pathlen);
> > - strncpy(n->on_path, path, pathlen);
> > - n->on_path[n->on_pathlen] = 0;
> > + strlcpy(n->on_path, path, pathlen);
> >
> > return pos;
> > }
> > diff -r bef7fbe25a9f -r d2784d93e760 xen/arch/powerpc/ofd_fixup.c
> > --- a/xen/arch/powerpc/ofd_fixup.c Mon Jan 29 14:59:42 2007 +0000
> > +++ b/xen/arch/powerpc/ofd_fixup.c Mon Jan 29 15:01:33 2007 +0000
> > @@ -267,7 +267,7 @@ static ofdn_t ofd_chosen_props(void *m,
> > &path[1], sizeof (path) - 1);
> > }
> >
> > - strcpy(bootargs, cmdline);
> > + strlcpy(bootargs, cmdline, sizeof(bootargs));
> > bsz = strlen(bootargs) + 1;
> > rm = sizeof (bootargs) - bsz;
> >
> >
> > _______________________________________________
> > Xen-staging mailing list
> > Xen-staging@lists.xensource.com
> > http://lists.xensource.com/xen-staging
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Re: [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy.
2007-01-30 7:11 ` Christoph Egger
@ 2007-01-30 13:25 ` Alex Williamson
2007-01-30 13:50 ` Aron Griffis
1 sibling, 0 replies; 6+ messages in thread
From: Alex Williamson @ 2007-01-30 13:25 UTC (permalink / raw)
To: Christoph Egger; +Cc: Aron Griffis, xen-devel
On Tue, 2007-01-30 at 08:11 +0100, Christoph Egger wrote:
> On Tuesday 30 January 2007 00:47, Aron Griffis wrote:
> > Hi Christoph,
> >
> > Was this patch floated on xen-devel and/or xen-ia64-devel? I'm having
> > trouble finding it, and I think I'm seeing some problems in it, see
> > below.
>
> I posted it to xen-devel. I'm not subscribed on ia64-devel.
>
> According to the troubles you pointed out indicates, that the
> ACPI header fields need one more byte for the NUL.
Sorry, we don't have the luxury of redefining the ACPI spec to add a
NULL byte to pad out the fields. This code is actually filling out fake
ACPI firmware tables. Thanks,
Alex
--
Alex Williamson HP Open Source & Linux Org.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy.
2007-01-30 7:11 ` Christoph Egger
2007-01-30 13:25 ` Alex Williamson
@ 2007-01-30 13:50 ` Aron Griffis
1 sibling, 0 replies; 6+ messages in thread
From: Aron Griffis @ 2007-01-30 13:50 UTC (permalink / raw)
To: Christoph Egger; +Cc: xen-devel
Christoph Egger wrote: [Tue Jan 30 2007, 02:11:47AM EST]
> On Tuesday 30 January 2007 00:47, Aron Griffis wrote:
> > Hi Christoph,
> >
> > Was this patch floated on xen-devel and/or xen-ia64-devel? I'm having
> > trouble finding it, and I think I'm seeing some problems in it, see
> > below.
>
> I posted it to xen-devel. I'm not subscribed on ia64-devel.
Thanks, I found it later. My mistake.
Aron
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-01-30 13:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <200701291502.l0TF2Md1000372@latara.uk.xensource.com>
2007-01-29 23:47 ` [Xen-staging] [xen-unstable] ia64 and ppc: Remove uses of strcpy and strncpy Aron Griffis
2007-01-30 7:11 ` Christoph Egger
2007-01-30 13:25 ` Alex Williamson
2007-01-30 13:50 ` Aron Griffis
2007-01-29 23:53 ` Aron Griffis
2007-01-30 0:06 ` Aron Griffis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.