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/25 03:06:42 UTC

[GitHub] [incubator-nuttx] Donny9 opened a new pull request #2739: fs/readdir: Must reserve a byte for the NUL terminator

Donny9 opened a new pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739


   ## Summary
   fs/readdir: Must reserve a byte for the NUL terminator
   ## Impact
   
   ## Testing
   
   


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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739#issuecomment-767535725


   32 char is defined by NuttX, but many file system support file name length more than 32 char, and then the generated disk image may contain the item with long name, we should don't crash or hang the system in this case at least just because the string isn't null terminated.


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



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

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 edited a comment on pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739#issuecomment-767535725


   32 char is defined by NuttX, but many file system support file name length more than 32 char, and then the generated disk image may contain the item with long name, we should don't crash or hang the system in this case at least just because the string isn't null terminated.
   
   > So is this for external files names not created by NuttX? Won't it be It will be a breaking change for systems that had say had say 32 and now this code makes it 31 chars.
   
   No, if the length is exactly 32 bytes, nothing change at all. The real difference is when the file name is longer than 32 bytes. Before the changing, we have a string with 33 char without null terminator. After the change, we have a string with 32 char and null terminator.


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



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

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739


   


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



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

Posted by GitBox <gi...@apache.org>.
Donny9 commented on pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739#issuecomment-767279936






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



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

Posted by GitBox <gi...@apache.org>.
davids5 commented on pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739#issuecomment-767498743


   So is this for external files names not created by NuttX?  Won't it be It will be a breaking change for systems that had say had say 32 and now this code makes it 31 chars.  


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



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

Posted by GitBox <gi...@apache.org>.
Donny9 removed a comment on pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739#issuecomment-767279936


   > ?
   Okay, the size of d_name is NAME_MAX + 1, and the maximum length of directory name is NAME_MAX, and the last bytes should be NULL character. And strncpy will not append '\0' when source is bigger than num, so we need reserve a byte for the NUL terminator, otherwise NAME_MAX doesn't mean anything.
   
   


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



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

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 edited a comment on pull request #2739:
URL: https://github.com/apache/incubator-nuttx/pull/2739#issuecomment-767535725


   32 char is defined by NuttX, but many file system support file name length more than 32 char, and then the generated disk image may contain the item with long name, we should don't crash or hang the system in this case at least just because the string isn't null terminated.
   
   > So is this for external files names not created by NuttX? Won't it be It will be a breaking change for systems that had say had say 32 and now this code makes it 31 chars.
   
   No, if the length is exactly 32 bytes, nothing change at all. The real difference is when the file name is longer than 32 bytes. Before the changing, we have a string with 33 char without null terminator. After the change, we have a string with 32 char and null terminator. The char after 32 bytes get cut in this case.


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