Commit 13dd6665ed18f72380ca596931d609bc108d4b82

Authored by AKASHI Takahiro
Committed by Alexander Graf
1 parent d178836bd2

distro: not taint environment variables if possible

The aim of this patch is not to have temporary variables used in
distro_bootcmd left as environment variables after run something.
See the discussion[1].
Without this patch, saveenv command also saves those variables, too.
While they are apparently safe, scsi_need_init can be harmful.

Please note that, in most cases, a variable should be converted to
hush's local variable, while "devplist" cannot because it is created
by "part" command as an environment variable.

[1] https://lists.denx.de/pipermail/u-boot/2018-December/350209.html

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

Showing 1 changed file with 7 additions and 6 deletions Side-by-side Diff

include/config_distro_bootcmd.h
... ... @@ -27,7 +27,7 @@
27 27  
28 28 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
29 29 "if " #devtypel " dev ${devnum}; then " \
30   - "setenv devtype " #devtypel "; " \
  30 + "devtype=" #devtypel "; " \
31 31 "run scan_dev_for_boot_part; " \
32 32 "fi\0"
33 33  
... ... @@ -37,7 +37,7 @@
37 37  
38 38 #define BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance) \
39 39 "bootcmd_" #devtypel #instance "=" \
40   - "setenv devnum " #instance "; " \
  40 + "devnum=" #instance "; " \
41 41 "run " #devtypel "_boot\0"
42 42  
43 43 #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
... ... @@ -77,7 +77,7 @@
77 77 "if ubi part ${bootubipart} && " \
78 78 "ubifsmount ubi${devnum}:${bootubivol}; " \
79 79 "then " \
80   - "setenv devtype ubi; " \
  80 + "devtype=ubi; " \
81 81 "run scan_dev_for_boot; " \
82 82 "fi\0"
83 83 #define BOOTENV_DEV_UBIFS BOOTENV_DEV_BLKDEV
84 84  
... ... @@ -205,11 +205,11 @@
205 205  
206 206 #ifdef CONFIG_SCSI
207 207 #define BOOTENV_RUN_SCSI_INIT "run scsi_init; "
208   -#define BOOTENV_SET_SCSI_NEED_INIT "setenv scsi_need_init; "
  208 +#define BOOTENV_SET_SCSI_NEED_INIT "scsi_need_init=; "
209 209 #define BOOTENV_SHARED_SCSI \
210 210 "scsi_init=" \
211 211 "if ${scsi_need_init}; then " \
212   - "setenv scsi_need_init false; " \
  212 + "scsi_need_init=false; " \
213 213 "scsi scan; " \
214 214 "fi\0" \
215 215 \
... ... @@ -444,7 +444,8 @@
444 444 "bootfstype; then " \
445 445 "run scan_dev_for_boot; " \
446 446 "fi; " \
447   - "done\0" \
  447 + "done; " \
  448 + "setenv devplist\0" \
448 449 \
449 450 BOOT_TARGET_DEVICES(BOOTENV_DEV) \
450 451 \