Re: Strange behaviour of 'exit' command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ian,

On Wed, Jun 12, 2019 at 11:42:24AM +0100, Ian Abbott wrote:
> I noticed some strange behaviour in the 'hush' shell when the 'sh' and
> 'exit' commands are used:
> 
> ---------------------------------
> barebox:/ sh
> barebox:/ exit
> t: No such file or directory
> barebox:/ echo $?
> 127
> barebox:/
> ---------------------------------

After some digging:

in common/hush.c get_user_input() we have:

	static char the_command[CONFIG_CBSIZE];

This string is used for user input and is unfortunately shared between
different shell instances. The 't' that is executed is the 't' from
'exit'. Try ' exit' instead and you'll see the shell trying to execute
'it' ;)

the_command should be dynamically allocated, but since in_str is
currently statically allocated there is no place in the code to free
the_command again after usage.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux