diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-02-02 12:53:58 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-02-02 12:53:58 -0600 |
commit | 7e032c4d2bbe3eec2f4e09e948c834ddcd20c2dd (patch) | |
tree | 6bd2bb9602d57d7cc2fc14127537363edae12252 /apps/system | |
parent | 5d6e18e0ba1c0164f6d0913b25510c11b14fcc27 (diff) | |
download | nuttx-7e032c4d2bbe3eec2f4e09e948c834ddcd20c2dd.tar.gz nuttx-7e032c4d2bbe3eec2f4e09e948c834ddcd20c2dd.tar.bz2 nuttx-7e032c4d2bbe3eec2f4e09e948c834ddcd20c2dd.zip |
CLE: Forgot to NUL terminate the command line
Diffstat (limited to 'apps/system')
-rw-r--r-- | apps/system/cle/cle.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/apps/system/cle/cle.c b/apps/system/cle/cle.c index 04d24bbec..f978327ea 100644 --- a/apps/system/cle/cle.c +++ b/apps/system/cle/cle.c @@ -536,7 +536,8 @@ static void cle_clrtoeol(FAR struct cle_s *priv) * * Description: * Make space for new text of size 'increment' at the specified cursor - * position. + * position. This function will not allow text grow beyound (linelen - 1) + * in size. * ****************************************************************************/ @@ -550,8 +551,9 @@ static bool cle_opentext(FAR struct cle_s *priv, uint16_t pos, uint16_t incremen * of 'increment' */ - if (priv->nchars + increment > priv->linelen) + if (priv->nchars + increment >= priv->linelen) { + CLE_BEL(priv); return false; } @@ -641,7 +643,7 @@ static void cle_showtext(FAR struct cle_s *priv) /* Loop for each column */ - for (column = 0; column < priv->nchars && column < priv->linelen; ) + for (column = 0; column < priv->nchars; ) { /* Perform TAB expansion */ @@ -937,5 +939,10 @@ int cle(FAR char *line, uint16_t linelen, FILE *instream, FILE *outstream) /* The editor loop */ - return cle_editloop(&priv); + ret = cle_editloop(&priv); + + /* Make sure that the line is NUL terminated */ + + line[priv.nchars] = '\0'; + return ret; } |