WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 0/3] Use string bound functions (take #2)

To: Keir Fraser <keir@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 0/3] Use string bound functions (take #2)
From: Stefan Berger <stefanb@xxxxxxxxxx>
Date: Mon, 29 Jan 2007 11:22:01 -0500
Cc: Christoph Egger <Christoph.Egger@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 29 Jan 2007 08:21:39 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C1E3CC36.86E6%keir@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx

xen-devel-bounces@xxxxxxxxxxxxxxxxxxx wrote on 01/29/2007 11:07:18 AM:

> On 29/1/07 14:22, "Christoph Egger" <Christoph.Egger@xxxxxxx> wrote:
>
> > I killed safe_strcpy() and almost all users from strcpy() and strncpy().
> > The remaining users are acm and acpi.


Thanks. This would have been it -- I am sure you did the same.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>


Index: root/xen-unstable.hg/xen/acm/acm_core.c
===================================================================
--- root.orig/xen-unstable.hg/xen/acm/acm_core.c
+++ root/xen-unstable.hg/xen/acm/acm_core.c
@@ -89,7 +89,9 @@ acm_set_policy_reference(u8 * buf, u32 b
    if (!acm_bin_pol.policy_reference_name)
        return -ENOMEM;

-    strcpy(acm_bin_pol.policy_reference_name, (char *)(buf + sizeof(struct acm_policy_reference_buffer)));
+    strlcpy(acm_bin_pol.policy_reference_name,
+            (char *)(buf + sizeof(struct acm_policy_reference_buffer)),
+            ntohl(pr->len));
    printk("%s: Activating policy %s\n", __func__, acm_bin_pol.policy_reference_name);
    return 0;
}
@@ -106,8 +108,9 @@ acm_dump_policy_reference(u8 *buf, u32 b

    memset(buf, 0, ret);
    pr_buf->len = htonl(strlen(acm_bin_pol.policy_reference_name) + 1); /* including stringend '\0' */
-    strcpy((char *)(buf + sizeof(struct acm_policy_reference_buffer)),
-           acm_bin_pol.policy_reference_name);
+    strlcpy((char *)(buf + sizeof(struct acm_policy_reference_buffer)),
+            acm_bin_pol.policy_reference_name,
+            buf_size - sizeof(struct acm_policy_reference_buffer));
    return ret;
}





> > When this is done, strcpy() and strncpy() can be removed.
>
> Okay, there are no live users of strcpy/strncpy/strcat/strncat (I fixed the
> acm uses and the acpi uses are dead macros that aren't used). So I've killed
> off those functions, #defined them to informative undefined labels, and
> implemented strlcat().
>
> sprintf() can go once the ia64 uses are fixed up.
>
>  -- Keir
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel