xiaoxiang781216 commented on code in PR #20440:
URL: https://github.com/apache/nuttx/pull/20440#discussion_r4174389745


##########
libs/libc/termios/lib_ttynamer.c:
##########
@@ -63,25 +65,36 @@ int ttyname_r(int fd, FAR char *buf, size_t buflen)
       return ENOTTY;
     }
 
-  if (buflen >= TTY_NAME_MAX)
+  /* The F_GETPATH handler copies the file path into the caller buffer
+   * bounded by PATH_MAX, not by any tty-specific limit, so the path must
+   * always land in a PATH_MAX-sized buffer first.  Only a caller buffer
+   * of that size can receive it directly.
+   */
+
+  if (buflen >= PATH_MAX)
     {
       return fcntl(fd, F_GETPATH, buf) < 0 ? get_errno() : 0;
     }
   else
     {
-      char name[TTY_NAME_MAX];
+      FAR char *path = lib_get_pathbuffer();

Review Comment:
   call lib_get_tempbuffer instead



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