jerpelea opened a new pull request, #21172:
URL: https://github.com/apache/nuttx/pull/21172

   ## Summary
   
   ttyname_r() passed the caller buffer straight to fcntl(F_GETPATH) whenever 
buflen >= TTY_NAME_MAX, but every FIOC_FILEPATH handler writes the path bounded 
by PATH_MAX and ignores the caller buffer size.  A tty registered under a 
nested /dev path, or reached through rpmsgfs, has a path longer than 
TTY_NAME_MAX and overwrote the caller buffer, silently corrupting memory behind 
a zero return code.  The small-buffer branch had the same defect against its 
own stack local char name[TTY_NAME_MAX].  Gate the direct write on PATH_MAX 
instead and stage the path through a PATH_MAX path buffer obtained via 
lib_get_tempbuffer(), returning ERANGE when it does not fit.
   
   Verified on sim:nsh with a test driver registered at an 85-character tty 
path: pre-fix, ttyname_r(buf, TTY_NAME_MAX) returned 0 and smashed the canaries 
behind the buffer, and the small-buffer branch panicked; post-fix both cases 
return ERANGE with the canaries intact.
   
   ## Impact
   
   RELEASE
   
   ## Testing
   
   CI


-- 
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