From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Christoph Egger" Subject: Re: [PATCH] Clean up and fix errors in strncpy -> strlcpy conversion Date: Tue, 30 Jan 2007 09:23:07 +0100 Message-ID: <200701300923.08382.Christoph.Egger@amd.com> References: <20070130011053.GE27235@fc.hp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20070130011053.GE27235@fc.hp.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Aron Griffis , xen-ia64-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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 > # Date 1170118368 18000 > # Node ID 23560e2248fd267bad6490113ed52d0a27d7e219 > # Parent 5e3b47bcc311e7698959f1fa79c4654190593499 > Clean up and fix errors in strncpy -> strlcpy conversion > > Signed-off-by: Aron Griffis > > 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