mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ian Abbott <abbotti@mev.co.uk>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: Strange behaviour of 'exit' command
Date: Thu, 13 Jun 2019 09:18:45 +0200	[thread overview]
Message-ID: <20190613071845.gbct6h5kg7mlpk3a@pengutronix.de> (raw)
In-Reply-To: <70b8a552-c423-9e74-ae80-5385a90e35ba@mev.co.uk>

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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2019-06-13  7:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 10:42 Ian Abbott
2019-06-13  7:18 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190613071845.gbct6h5kg7mlpk3a@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=abbotti@mev.co.uk \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox