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

Re: [Xen-devel] [PATCH xtf] libc: Fix strcpy() assignment mistake



On 11/10/17 14:07, Paul Semel wrote:
> From: Paul Semel <phentex@xxxxxxxxx>
>
> the strcpy function was doing a comparison instead of doing an
> assignment.
>
> Signed-off-by: Paul Semel <phentex@xxxxxxxxx>
>
> Reviewed-by: Pawel Wieczorkiewicz <wipawel@xxxxxxxxx>
> Reviewed-by: Bjoern Doebel <doebel@xxxxxxxxx>
> Reviewed-by: Martin Pohlack <mpohlack@xxxxxxxxx>

Oops.  This issue is hidden due to __builtin_strcpy() optimising all
in-tree callsites.

Reviewed-and-tested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, and
pushed.

> ---
>  common/libc/string.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/libc/string.c b/common/libc/string.c
> index 94acc7e..967f2fa 100644
> --- a/common/libc/string.c
> +++ b/common/libc/string.c
> @@ -24,7 +24,7 @@ size_t strnlen(const char *str, size_t max)

It looks like git isn't terribly happy with the (strcpy) preprocessor
trick.  I did a double-take when I first read the patch.

~Andrew

>  {
>      char *p = dst;
>  
> -    while ( *p++ == *src++ )
> +    while ( (*p++ = *src++) )
>          ;
>  
>      return dst;


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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