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

Re: [Xen-devel] [PATCH v3] vsprintf: Make sure argument to %pX specifier is valid



>>> On 18.02.15 at 16:39, <boris.ostrovsky@xxxxxxxxxx> wrote:
> --- a/xen/common/vsprintf.c
> +++ b/xen/common/vsprintf.c
> @@ -269,7 +269,28 @@ static char *pointer(char *str, char *end, const char 
> **fmt_ptr,
>  {
>      const char *fmt = *fmt_ptr, *s;
>  
> -    /* Custom %p suffixes. See XEN_ROOT/docs/misc/printk-formats.txt */
> +    /*
> +     * For custom %p suffixes (see XEN_ROOT/docs/misc/printk-formats.txt)
> +     * if arg pointer is bogus then print pointer value in parentheses.
> +     */
> +    if ( (unsigned long)arg < HYPERVISOR_VIRT_START )
> +    {
> +        switch (fmt[1])
> +        {
> +        case 'h':
> +        case 's':
> +        case 'S':
> +        case 'v':
> +            ++*fmt_ptr;
> +            if ( str < end )
> +                *str++ = '(';
> +            str = number(str, end, (unsigned long)arg, 16, -1, -1, ZEROPAD);
> +            if ( str < end )
> +                *str++ = ')';

You should take existing code as reference when adding to it:
Both increments above need to happen unconditionally.

Jan


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


 


Rackspace

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