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

Chris Johns chrisj at rtems.org
Thu Oct 15 20:29:42 UTC 2020


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