Re: [PATCH v7 07/10] vsprintf: Consolidate handling of unknown pointer specifiers

From: Sergey Senozhatsky
Date: Thu Apr 18 2019 - 09:45:50 EST


On (04/17/19 13:53), Petr Mladek wrote:
[..]
> char *ip_addr_string(char *buf, char *end, const void *ptr,
> struct printf_spec spec, const char *fmt)
> {
> + char *err_fmt_msg;
> +
> switch (fmt[1]) {
> case '6':
> return ip6_addr_string(buf, end, ptr, spec, fmt);
> @@ -1457,7 +1459,8 @@ char *ip_addr_string(char *buf, char *end, const void *ptr,
> }}
> }
>
> - return ptr_to_id(buf, end, ptr, spec);
> + err_fmt_msg = fmt[0] == 'i' ? "(%pi?)" : "(%pI?)";
> + return string_nocheck(buf, end, err_fmt_msg, spec);
> }

We cannot err on fmt[0] here, can we. Both %pi and %pI are OK
and handled by pointer():

switch (fmt[0]) {
case 'I':
case 'i':
return ip_addr_string(buf, end, ptr, spec, fmt);


It's fmt[1] which can be unrecognized:

switch (fmt[1]) {
case '6':
case '4':
case 'S':
}

-ss