[PATCH] rtems-fdt / shell - Fix string truncation warning

Frank Kühndel frank.kuehndel at embedded-brains.de
Fri Oct 16 16:16:44 UTC 2020


Hello Chris,

On 10/15/20 10:29 PM, Chris Johns wrote:
> On 16/10/20 7:24 am, Joel Sherrill wrote:
>> On Thu, Oct 15, 2020 at 2:13 PM Chris Johns <chrisj at rtems.org
>> <mailto:chrisj at rtems.org>> wrote:
>>     On 15/10/20 10:27 pm, Frank Kuehndel wrote:
>>     > From: Frank Kühndel <frank.kuehndel at embedded-brains.de
>>     <mailto:frank.kuehndel at embedded-brains.de>>
>>     >
>>     > The compiler warning was:
>>     >
>>     > ../../../cpukit/libmisc/rtems-fdt/rtems-fdt.c:267:5: warning:
>>     > 'strncpy' specified bound depends on the length of the source argument
>>     >   267 |     strncpy(path, name, namelen);
>>     >       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>     >
>>     > It turns out that the `strncpy()` nor the buffer `path` is needed when
>>     > one uses `strncmp()` instead of `strcmp()`. This needs some change to
>>     > the algorithm but has the advantage that `name` is never truncated
>>     > to the size of the buffer `path`.
>>     >
>>     > Note:
>>     >
>>     > rtems-fdt.c, rtems-fdt-shell.c and cpukit/include/rtems/rtems-fdt.h
>>     > seem to be dead code.
>>
>>     We cannot tell this is as a user may depend on it. With this command I know
>>     users on Zynq platforms that use FDT to map PL logic to drivers. The command is
>>     very much in use and is used as a PS to PL testing method.

This statement was not meant as an offense. I spent a lot of time trying
to figure out where and how this code was used - without result. With
this statement, I hoped to trigger a reaction by someone indicating that
he/she knows the code can be removed or that he/she knows the code is in
use. I am sorry that my text was not appropriate.

I will send a patch v2 without this text on Monday.

Frank

>>
>>     > They implement a shell command `fdt` but that
>>     > command is not part of the shell nor of any macro in
>>     > cpukit/include/rtems/shellconfig.h.
>>
>>     It have been missed and needs be added. Adding something in shellconfig.h would
>>     be a help.
>>
>> Does that mean it also is not in the Shell manual?
>>
> Yes it seems so:
> 
> (sphinx38) ruru rtems-docs.git $ grep -r fdt shell
> (sphinx38) ruru rtems-docs.git $
> 
> Chris
> 



More information about the devel mailing list