[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] Clean up and fix errors in strncpy -> strlcpy conversion



On Tuesday 30 January 2007 02:10, Aron Griffis wrote:
> This patch is for the staging tree.  Please apply.
>
> # HG changeset patch
> # User Aron Griffis <aron@xxxxxx>
> # Date 1170118368 18000
> # Node ID 23560e2248fd267bad6490113ed52d0a27d7e219
> # Parent  5e3b47bcc311e7698959f1fa79c4654190593499
> Clean up and fix errors in strncpy -> strlcpy conversion
>
> Signed-off-by: Aron Griffis <aron@xxxxxx>
>
> diff -r 5e3b47bcc311 -r 23560e2248fd xen/arch/ia64/xen/dom_fw.c
> --- a/xen/arch/ia64/xen/dom_fw.c      Mon Jan 29 22:43:51 2007 +0000
> +++ b/xen/arch/ia64/xen/dom_fw.c      Mon Jan 29 19:52:48 2007 -0500
> @@ -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) */
> -     strlcpy(xsdt->signature, XSDT_SIG, sizeof(xsdt->signature));
> +     memcpy(xsdt->signature, XSDT_SIG, sizeof(xsdt->signature));
>       /* 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;
> -     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));
> +     safe_strcpy(xsdt->oem_id, "XEN");
> +     safe_strcpy(xsdt->oem_table_id, "Xen/ia64");
> +     safe_strcpy(xsdt->asl_compiler_id, "XEN");
>       xsdt->asl_compiler_revision = (xen_major_version() << 16) |
>               xen_minor_version();

In my patch, safe_strcpy() is gone. And anyway, if safe_strcpy works as 
expected, then apart from the return value there's no difference to 
strlcpy().

The ACPI header fields simply need one more byte for the NUL.

Christoph



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.