Junbo-Zheng opened a new pull request, #21495:
URL: https://github.com/apache/nuttx/pull/21495

   
   ## Summary
   
   `lib_get_tempbuffer()` returns NULL when the temp buffer pool is
   exhausted and the fallback allocation fails, but `ttyname_r()` passed
   the pointer straight to `fcntl(F_GETPATH)` and `strlen()` without a
   NULL check, dereferencing NULL on allocation failure (**reported by
   static analysis, Coverity NULL_RETURNS**).
   
   Every other caller of `lib_get_tempbuffer()` in the tree already
   handles the NULL return (`fs/hostfs/hostfs.c`, `libs/libc/misc/lib_glob.c`,
   `libs/libc/grp/lib_find_grpfile.c`, `libs/libbuiltin/libgcc/gcov.c`);
   `ttyname_r()` was the only one that did not. The fix returns `ENOMEM`,
   matching both the error contract of `ttyname_r()` and the convention
   used by those callers.
   
   ## Impact
   
   - **Users**: None in the normal path; on temp-buffer allocation
     failure, `ttyname_r()` now returns an error instead of crashing.
   - **Build**: None.
   - **Hardware**: None.
   - **Documentation**: None.
   - **Security & Compatibility**: None.
   
   ## Testing
   
   sim:nsh
   
   Signed-off-by: Junbo Zheng <[email protected]>
   


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