raiden00pl opened a new pull request, #3844:
URL: https://github.com/apache/nuttx-apps/pull/3844

   ## Summary
   nsh_parse_command() and nsh_parse_cmdparm() printed "too many arguments" 
when argc exceeded CONFIG_NSH_MAXARGUMENTS but still ran the command. The 
command then ran with all arguments, or, with more than MAX_ARGV_ENTRIES - 1 
words, with the words after that silently dropped (they are not parsed).
   
   Report the error and fail the command instead, as a shell does when exec() 
fails with E2BIG. NSH commands already reject argc above their maxargs in 
nsh_command(); this also covers builtin and file applications.
   
   ## Impact
   bugfix
   
   ## Testing
   
   Tested on sim:nsh (CONFIG_NSH_MAXARGUMENTS=7).                               
                                                                                
                                                                                
               
                                                                                
                                                                                
                                                                                
                                    
   Before:                                                                      
                                                                                
                                                                                
           
                                                                                
                                                                                
                                                                                
                                    
     ```                                                                        
                                                                                
                                                                                
                                    
     nsh> hello 1 2 3 4 5 6 7 8                                                 
                                                                                
                                                                                
                                    
     nsh: hello: too many arguments                                             
                                                                                
                                                                                
                                    
     Hello, World!!                                                             
                                                                                
                                                                                
                                    
     nsh> echo $?                                                               
                                                                                
                                                                                
                                    
     0                                                                          
                                                                                
                                                                                
                                    
     nsh> echo 1 2 3 4 5 6 7 8                                                  
                                                                                
                                                                                
                                    
     nsh: echo: too many arguments                                              
                                                                                
                                                                                
                                    
     nsh: echo: too many arguments                                              
                                                                                
                                                                                
                                    
     nsh> echo $?                                                               
                                                                                
                                                                                
                                    
     1                                                                          
                                                                                
                                                                                
                                    
     ```                                                                        
                                                                                
                                                                                
                                    
                                                                                
                                                                                
                                                                                
                                    
   After:                                                                       
                                                                                
                                                                                
                                  
                                                                                
                                                                                
                                                                                
                                    
     ```                                                                        
                                                                                
                                                                                
                                    
     nsh> hello 1 2 3 4 5 6 7 8                                                 
                                                                                
                                                                                
                                    
     nsh: hello: too many arguments                                             
                                                                                
                                                                                
                                    
     nsh> echo $?                                                               
                                                                                
                                                                                
                                    
     1                                                                          
                                                                                
                                                                                
                                    
     nsh> echo 1 2 3 4 5 6 7 8                                                  
                                                                                
                                                                                
                                    
     nsh: echo: too many arguments                                              
                                                                                
                                                                                
                                    
     nsh> echo $?                                                               
                                                                                
                                                           No changes this 
session                                  
     1                                                                          
                                                                                
                                                                                
                                    
     ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to