You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/01/26 04:45:27 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #2739: fs/readdir: Must reserve a byte for the NUL terminator

xiaoxiang781216 commented on pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739#issuecomment-767285544


   https://github.com/apache/incubator-nuttx/blob/master/libs/libc/string/lib_strncpy.c#L69-L94
   ```
     FAR char *ret = dest;     /* Value to be returned */
     FAR char *end = dest + n; /* End of dest buffer + 1 byte */
   
     while ((dest != end) && (*dest++ = *src++) != '\0')
       {
       }
   ```
   From the above code, if directory entry length is bigger than NAME_MAX and we call strncpy(, , NAME_MAX + 1), the last byte will be a non zero char.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org