1. 12 6月, 2014 1 次提交
  2. 06 6月, 2014 1 次提交
    • S
      Fix hush to give the correct return code for a simple command · 587e1d43
      Simon Glass 提交于
      When a simple command like 'false' is provided, hush should return the
      result of that command. However, hush only does this if the
      FLAG_EXIT_FROM_LOOP flag is provided. Without this flag, hush will
      happily execute the empty string command immediate after 'false' and
      then return a success code.
      
      This behaviour does not seem very useful, and requiring the flag also
      seems wrong, since it means that hush will execute only the first command
      in a sequence.
      
      Add a check for empty string and fall out of the loop in that case. That
      at least fixes the simple command case. This is a change in behaviour but
      it is unlikely that the old behaviour would be considered correct in any
      case.
      Reported-by: NStefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
      Signed-off-by: NSimon Glass <sjg@chromium.org>
      587e1d43
  3. 30 5月, 2014 5 次提交
  4. 13 5月, 2014 1 次提交
    • K
      hush shell: Avoid string write overflow when entering max cmd length · 5c50a92b
      Kristian Otnes 提交于
      console_buffer array is defined to be CONFIG_SYS_CBSIZE + 1 long,
      whereas the_command array only CONFIG_SYS_CBSIZE long. Subsequent
      use of strcpy(the_command, console_buffer) will write final \0
      terminating byte outside the_command array when entering a command
      of max length.
      
      Signed-off-by: Kristian Otnes <kotnes <at> cisco <dot> com>
      5c50a92b
  5. 07 3月, 2014 1 次提交
    • S
      hush: fix some quoted variable expansion issues · fe9ca3d3
      Stephen Warren 提交于
      The following shell command fails:
      
      if test -z "$x"; then echo "zero"; else echo "non-zero"; fi
      
      (assuming $x does not exist, it prints "non-zero" rather than "zero").
      
      ... since "$x" expands to nothing, and the argument is completely
      dropped, causing too few to be passed to -z, causing cmd_test() to
      error out early.
      
      This is because when variable expansions are processed by make_string(),
      the expanded results are concatenated back into a new string. However,
      no quoting is applied when doing so, so any empty variables simply don't
      generate any parameter when the combined string is parsed again.
      
      Fix this by explicitly replacing quoting any argument that was originally
      quoted when re-generating a string from the already-parsed argument list.
      
      This also fixes loss of whitespace in commands such as:
      
      setenv space " "
      setenv var " 1${space}${space} 2 "
      echo ">>${var}<<"
      Reported-by: NRussell King <linux@arm.linux.org.uk>
      Acked-by: NSimon Glass <sjg@chromium.org>
      Signed-off-by: NStephen Warren <swarren@wwwdotorg.org>
      fe9ca3d3
  6. 24 7月, 2013 1 次提交
  7. 04 2月, 2013 1 次提交
  8. 05 11月, 2012 1 次提交
    • K
      common/misc: sparse fixes · 199adb60
      Kim Phillips 提交于
      command.c:44:38: error: bad constant expression
      dlmalloc.c:1468:2: warning: Using plain integer as NULL pointer
      dlmalloc.c:1468:5: warning: Using plain integer as NULL pointer
      dlmalloc.c:2176:12: warning: Using plain integer as NULL pointer
      dlmalloc.c:2179:31: warning: Using plain integer as NULL pointer
      dlmalloc.c:2382:14: warning: Using plain integer as NULL pointer
      dlmalloc.c:2436:14: warning: Using plain integer as NULL pointer
      dlmalloc.c:2582:31: warning: Using plain integer as NULL pointer
      dlmalloc.c:2585:17: warning: Using plain integer as NULL pointer
      dlmalloc.c:2646:14: warning: Using plain integer as NULL pointer
      dlmalloc.c:2659:19: warning: Using plain integer as NULL pointer
      dlmalloc.c:2692:19: warning: Using plain integer as NULL pointer
      dlmalloc.c:2707:19: warning: Using plain integer as NULL pointer
      dlmalloc.c:2708:14: warning: Using plain integer as NULL pointer
      dlmalloc.c:2786:31: warning: Using plain integer as NULL pointer
      dlmalloc.c:2801:12: warning: Using plain integer as NULL pointer
      dlmalloc.c:2801:22: warning: Using plain integer as NULL pointer
      dlmalloc.c:2926:27: warning: Using plain integer as NULL pointer
      dlmalloc.c:2928:14: warning: Using plain integer as NULL pointer
      dlmalloc.c:2929:12: warning: Using plain integer as NULL pointer
      dlmalloc.c:3075:14: warning: Using plain integer as NULL pointer
      hush.c:292:14: warning: symbol 'last_return_code' was not declared. Should it be static?
      hush.c:293:5: warning: symbol 'nesting_level' was not declared. Should it be static?
      hush.c:2175:20: warning: Using plain integer as NULL pointer
      hush.c:2175:34: warning: Using plain integer as NULL pointer
      hush.c:2210:41: warning: Using plain integer as NULL pointer
      hush.c:2216:45: warning: Using plain integer as NULL pointer
      hush.c:2249:25: warning: Using plain integer as NULL pointer
      hush.c:2332:13: warning: symbol 'new_pipe' was not declared. Should it be static?
      hush.c:2390:5: warning: symbol 'reserved_word' was not declared. Should it be static?
      hush.c:2927:5: warning: symbol 'parse_stream' was not declared. Should it be static?
      hush.c:3127:6: warning: symbol 'mapset' was not declared. Should it be static?
      hush.c:3133:6: warning: symbol 'update_ifs_map' was not declared. Should it be static?
      hush.c:3161:5: warning: symbol 'parse_stream_outer' was not declared. Should it be static?
      hush.c:3295:34: warning: Using plain integer as NULL pointer
      hush.c:3631:5: warning: symbol 'do_showvar' was not declared. Should it be static
      image.c:1282:29: warning: Using plain integer as NULL pointer
      image.c:1315:41: warning: Using plain integer as NULL pointer
      image.c:1330:25: warning: Using plain integer as NULL pointer
      image.c:1706:25: warning: Using plain integer as NULL pointer
      main.c:510:10: warning: symbol 'hist_num' was not declared. Should it be static?
      main.c:512:5: warning: symbol 'hist_list' was not declared. Should it be static?
      main.c:513:6: warning: symbol 'hist_lines' was not declared. Should it be static?
      usb_storage.c:195:6: warning: symbol 'usb_show_progress' was not declared. Should it be static?
      usb_storage.c:440:48: warning: Using plain integer as NULL pointer
      usb_storage.c:503:5: warning: symbol 'usb_stor_BBB_comdat' was not declared. Should it be static?
      usb_storage.c:551:5: warning: symbol 'usb_stor_CB_comdat' was not declared. Should it be static?
      usb_storage.c:629:55: warning: Using plain integer as NULL pointer
      usb_storage.c:620:5: warning: symbol 'usb_stor_CBI_get_status' was not declared. Should it be static?
      usb_storage.c:675:43: warning: Using plain integer as NULL pointer
      usb_storage.c:668:5: warning: symbol 'usb_stor_BBB_clear_endpt_stall' was not declared. Should it be static?
      usb_storage.c:679:5: warning: symbol 'usb_stor_BBB_transport' was not declared. Should it be static?
      usb_storage.c:801:5: warning: symbol 'usb_stor_CB_transport' was not declared. Sh
      xyzModem.c:104:1: warning: symbol 'CYGACC_COMM_IF_GETC_TIMEOUT' was not declared. Should it be static?
      xyzModem.c:122:1: warning: symbol 'CYGACC_COMM_IF_PUTC' was not declared. Should it be static?
      xyzModem.c:169:1: warning: symbol 'parse_num' was not declared. Should it be stat
      
      note: hush.c's nesting_level deleted because not used.
      Signed-off-by: NKim Phillips <kim.phillips@freescale.com>
      199adb60
  9. 03 9月, 2012 2 次提交
    • J
      hush: Don't parse the contents of a dereferenced var · a005f19e
      Joe Hershberger 提交于
      When a variable which contains a user-supplied value is dereferenced
      (e.g. to be echo'ed), make sure that the value is not further parsed
      by hush.
      
      Set the hush local variable "HUSH_NO_EVAL=1" to enable this behavior.
      
      Without this patch, a sequence like this occurs:
      
      	Panda # env set my_user_string Bob\'s favorite device
      	Panda # print my_user_string
      	my_user_string=Bob's favorite device
      	Panda # echo $my_user_string
      	syntax error hush.c:3007
      
      With this patch, it looks like this:
      
      	Panda # HUSH_NO_EVAL=1
      	Panda # env set my_user_string Bob\'s favorite device
      	Panda # print my_user_string
      	my_user_string=Bob's favorite device
      	Panda # echo $my_user_string
      	Bob's favorite device
      Signed-off-by: NJoe Hershberger <joe.hershberger@ni.com>
      a005f19e
    • J
      hush: Add default value substitution support · 641b0d37
      Joe Hershberger 提交于
      Use standard sh syntax:
      ${VAR:-default}
      	Use default value: if VAR is set and non-null, expands to $VAR.
      	Otherwise, expands to default.
      ${VAR:=default}
      	Set default value: if VAR is set and non-null, expands to $VAR.
      	Otherwise, sets hush VAR to default and expands to default.
      ${VAR:+default}
      	If VAR is set and non-null, expands to the empty string.
      	Otherwise, expands to default.
      Signed-off-by: NJoe Hershberger <joe.hershberger@ni.com>
      641b0d37
  10. 21 6月, 2012 1 次提交
  11. 07 3月, 2012 3 次提交
  12. 22 11月, 2011 1 次提交
  13. 27 10月, 2011 1 次提交
  14. 18 10月, 2011 1 次提交
  15. 11 5月, 2011 1 次提交
  16. 29 11月, 2010 2 次提交
  17. 30 10月, 2010 1 次提交
  18. 25 7月, 2010 1 次提交
  19. 05 7月, 2010 1 次提交
    • W
      Make sure that argv[] argument pointers are not modified. · 54841ab5
      Wolfgang Denk 提交于
      The hush shell dynamically allocates (and re-allocates) memory for the
      argument strings in the "char *argv[]" argument vector passed to
      commands.  Any code that modifies these pointers will cause serious
      corruption of the malloc data structures and crash U-Boot, so make
      sure the compiler can check that no such modifications are being done
      by changing the code into "char * const argv[]".
      
      This modification is the result of debugging a strange crash caused
      after adding a new command, which used the following argument
      processing code which has been working perfectly fine in all Unix
      systems since version 6 - but not so in U-Boot:
      
      int main (int argc, char **argv)
      {
      	while (--argc > 0 && **++argv == '-') {
      /* ====> */	while (*++*argv) {
      			switch (**argv) {
      			case 'd':
      				debug++;
      				break;
      			...
      			default:
      				usage ();
      			}
      		}
      	}
      	...
      }
      
      The line marked "====>" will corrupt the malloc data structures and
      usually cause U-Boot to crash when the next command gets executed by
      the shell.  With the modification, the compiler will prevent this with
      an
      	error: increment of read-only location '*argv'
      
      N.B.: The code above can be trivially rewritten like this:
      
      	while (--argc > 0 && **++argv == '-') {
      		char *arg = *argv;
      		while (*++arg) {
      			switch (*arg) {
      			...
      Signed-off-by: NWolfgang Denk <wd@denx.de>
      Acked-by: NMike Frysinger <vapier@gentoo.org>
      54841ab5
  20. 30 6月, 2010 2 次提交
  21. 03 10月, 2009 1 次提交
  22. 10 8月, 2009 1 次提交
  23. 13 6月, 2009 1 次提交
    • W
      General help message cleanup · a89c33db
      Wolfgang Denk 提交于
      Many of the help messages were not really helpful; for example, many
      commands that take no arguments would not print a correct synopsis
      line, but "No additional help available." which is not exactly wrong,
      but not helpful either.
      
      Commit ``Make "usage" messages more helpful.'' changed this
      partially. But it also became clear that lots of "Usage" and "Help"
      messages (fields "usage" and "help" in struct cmd_tbl_s respective)
      were actually redundant.
      
      This patch cleans this up - for example:
      
      Before:
      	=> help dtt
      	dtt - Digital Thermometer and Thermostat
      
      	Usage:
      	dtt         - Read temperature from digital thermometer and thermostat.
      
      After:
      	=> help dtt
      	dtt - Read temperature from Digital Thermometer and Thermostat
      
      	Usage:
      	dtt
      Signed-off-by: NWolfgang Denk <wd@denx.de>
      a89c33db
  24. 12 2月, 2009 1 次提交
  25. 28 1月, 2009 2 次提交
  26. 19 10月, 2008 2 次提交
  27. 21 8月, 2008 1 次提交
  28. 14 7月, 2008 1 次提交
  29. 21 5月, 2008 1 次提交
    • W
      Big white-space cleanup. · 53677ef1
      Wolfgang Denk 提交于
      This commit gets rid of a huge amount of silly white-space issues.
      Especially, all sequences of SPACEs followed by TAB characters get
      removed (unless they appear in print statements).
      
      Also remove all embedded "vim:" and "vi:" statements which hide
      indentation problems.
      Signed-off-by: NWolfgang Denk <wd@denx.de>
      53677ef1