poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Fix buffer overflow when too long a command is typed


From: Jose E. Marchesi
Subject: Re: [PATCH] Fix buffer overflow when too long a command is typed
Date: Sat, 21 Mar 2020 12:48:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi JOhn.
Ouch, OK for master! 

    ---
     src/pk-cmd.c | 11 +++++++++--
     1 file changed, 9 insertions(+), 2 deletions(-)
    
    diff --git a/src/pk-cmd.c b/src/pk-cmd.c
    index dde7cf2c..a5378b0b 100644
    --- a/src/pk-cmd.c
    +++ b/src/pk-cmd.c
    @@ -292,9 +292,16 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, 
char *prefix)
     
       /* Get the command name.  */
       i = 0;
    +  memset (cmd_name, 0, MAX_CMD_NAME);
       while (isalnum (*p) || *p == '_' || *p == '-' || *p == ':')
    -    cmd_name[i++] = *(p++);
    -  cmd_name[i] = '\0';
    +    {
    +      if (i >= MAX_CMD_NAME - 1)
    +   {
    +     pk_printf (_("%s: command not found.\n"), cmd_name);
    +     return 0;
    +   }
    +      cmd_name[i++] = *(p++);
    +    }
     
       /* Look for the command in the prefix table.  */
       cmd = pk_trie_get_cmd (cmds_trie, cmd_name);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]