On 2020/02/24 11:56, Stefan Sperling wrote:
> These functions will compute the wrong display width for input which is
> already a hex string. This bug doesn't trigger because we never actually
> pass an ASCII hex string in, but it is still a bug.
>
> ASCII hex strings are printable ASCII, so there's no reason to have a
> special case for them.
>
> This special case for "0x" was added in r1.60 of ifconfig.c ("Add support for
> nwkey and powersave; from NetBSD") by millert. At that time, the print_string
> function did not compute a length, and ifconfig was still using print_string
> to print WEP keys to stdout, which seems to be why the check for "0x" existed.
> WEP keys could be either printable ASCII or ASCII hex.
>
> Later on, phessler and I copied the same check to len_string which is based
> on print_string.
>
> We don't print keys nowadays, and these functions are used only to print
> binary data SSIDs (ASCII hex is an output, never an input).
>
> So we can simplify this.
>
> ok?
We do still need the 0x special case otherwise the user won't be able
to figure out how to connect to networks with certain names without
referring to an ascii-hex table.