This is an automated email from the ASF dual-hosted git repository.

archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 0640d3f55 nshlib/nsh_fsutils.c: fix getpid_callback function read size
0640d3f55 is described below

commit 0640d3f550f44547d12f6a57a14cc751520aaf17
Author: Michal Lenc <michall...@seznam.cz>
AuthorDate: Wed Mar 26 16:49:34 2025 +0100

    nshlib/nsh_fsutils.c: fix getpid_callback function read size
    
    Commit 5330966 replaced local static buffer with malloc allocated
    lib_get_pathbuffer. This however prevents the usage of sizeof(buffer)
    in the follow up read function, therefore the read size has to be
    specified as PATH_MAX - 1.
    
    This fixes the functionality of pidof function call (and subsequently
    pkill call that uses pidof).
    
    Signed-off-by: Michal Lenc <michall...@seznam.cz>
---
 nshlib/nsh_fsutils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nshlib/nsh_fsutils.c b/nshlib/nsh_fsutils.c
index c3793b206..878c1d18e 100644
--- a/nshlib/nsh_fsutils.c
+++ b/nshlib/nsh_fsutils.c
@@ -98,7 +98,7 @@ static int getpid_callback(FAR struct nsh_vtbl_s *vtbl,
       return 0;
     }
 
-  len = read(fd, buffer, sizeof(buffer) - 1);
+  len = read(fd, buffer, PATH_MAX - 1);
   close(fd);
   if (len < 0)
     {

Reply via email to