Skip to contentSkip to conversation

Use string bound functions (take #2)

PATCH In review Christoph Egger 4 participants 6 messages Jan 29, 2007 – Jan 30, 2007

lore
Share & tools
lore
#0 lore raw

cover Use string bound functions (take #2)

Hi!

I killed safe_strcpy() and almost all users from strcpy() and strncpy(). The remaining users are acm and acpi.
When this is done, strcpy() and strncpy() can be removed.

patch 1/3:
Changes arch-independent code.
Warning: Since tools re-uses libelf, this breaks the tool-building of the Linux distris, whose glibc have NO strlcpy/strlcat.
Solaris and *BSD are fine. They have these functions.
Keir, it's up to you if you apply this or if you wait until a fix for the tools is available.

patch 2/3:
Changes for x86 platform.

patch 3/3:
Changes for ppc/ia64 platforms.
Warning: Due to lack of hw, these two patches are NOT even compile-tested. IA64 and PPC maintainers, please verify.

#1 lore raw
Quoted 3 lines · Christoph Egger

I killed safe_strcpy() and almost all users from strcpy() and strncpy(). The remaining users are acm and acpi.
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

#2 lore raw

[email protected] wrote on 01/29/2007 11:07:18 AM:

Quoted 3 lines · Christoph Egger
Quoted 2 lines

I killed safe_strcpy() and almost all users from strcpy() and

strncpy().

Quoted 1 line
Quoted 1 line

The remaining users are acm and acpi.

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

xen-unstable.hg/xen/acm/acm_core.c +0 -1
Index: 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;

}

Quoted 3 lines
Quoted 1 line

When this is done, strcpy() and strncpy() can be removed.

Okay, there are no live users of strcpy/strncpy/strcat/strncat (I fixed

the

Quoted 1 line

acm uses and the acpi uses are dead macros that aren't used). So I've

killed

Quoted 5 lines

off those functions, #defined them to informative undefined labels, and implemented strlcat().

sprintf() can go once the ia64 uses are fixed up.

Quoted 7 lines

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 8 lines · Stefan Berger
Quoted 4 lines
Quoted 4 lines · Christoph Egger
Quoted 3 lines
Quoted 3 lines

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.

Same for the first one. A bit different for the second one (but I¹m sure it¹s okay either way: there¹s already a test against buf_size earlier in that function). I¹d appreciate it if you glance an eye over it when it hits the public tree later on.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
In reply to Keir Fraser
Quoted 11 lines · Keir Fraser
Quoted 3 lines · Christoph Egger

I killed safe_strcpy() and almost all users from strcpy() and strncpy(). The remaining users are acm and acpi.
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.

Great! When do these changes appear in the public tree?

Christoph

#5 lore raw
Quoted 8 lines · Christoph Egger
Quoted 6 lines

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.

Great! When do these changes appear in the public tree?

Some are already in. The rest should push today; hopefully regression tests will pass and the tree will get pushed automatically.

-- Keir