[U-Boot] [PATCH v6 3/3] GPT: provide commands to selectively rename partitions

Lothar Waßmann
2017-07-03T06:40:44Z

Hi,

> The underlying cause of the problem is that u-boot's implementations
> of strlen() and the CLI handle strings differently. The former
>
"u-boot's implementation" is conformant with the standard and well
documented libc implementation that exists since the dawn of C
programming.

> terminates strings only on NULLs, while the latter terminates strings
> *either* on NULLs or on semicolons. Reading the partition table
> back from a device's GPT results in a string with a NULL only at the
> very end, but with one semicolon per partition. Running 'gpt verify
> mmc 0 $partitions" or 'gpt write mmc 0 $partitions' therefore causes a
> crash if the user has previously typed 'setenv partitions 1;2;3;4;5;'
> rather than 'setenv partitions "1;2;3;4;5;"'. In the former case,
> the partitions string ends up being '1' without NULL-termination,
>
That's nonsense. _Every_ string in the environment is NULL terminated.
In the former case of your example the characters after the first
semicolon are interpreted as commands and lead to an error message
Unknown command '2' - try 'help'
...
because the ';' is treated as a command terminator by the parser
unless quoted.

Lothar WaÃŸmann