From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= Date: Mon, 3 Jul 2017 08:40:44 +0200 Subject: [U-Boot] [PATCH v6 3/3] GPT: provide commands to selectively rename partitions In-Reply-To: References: <20170610065138.2410A120BB0@gemini.denx.de> <1497137617-772-1-git-send-email-alison@peloton-tech.com> <20170612074557.E32A3120432@gemini.denx.de> <20170618110357.103A8120607@gemini.denx.de> <20170627090514.60272dd1@karo-electronics.de> Message-ID: <20170703084044.2b86bd40@karo-electronics.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de 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=C3=9Fmann