On 03/09/2020 16:46, Aschref Ben-Thabet wrote:

From: Aschref Ben Thabet <aschref.ben-tha...@embedded-brains.de>

strncpy
Please use the strncpy() style for functions in commit messages and comments.
is unsafe if the terminating NULL

There are NULL pointers and NUL characters, see

https://www.man7.org/linux/man-pages/man7/ascii.7.html

  is missing, as it may copy
more characters than fit in the destination area
No, the strncpy() does not overwrite the destination area if the size parameter is valid. I doesn't terminate the destination string if the source is too long.

Replace it by the safer strlcpy() and fix the string
turncation warnings.
---
  bsps/shared/dev/display/disp_hcms29xx.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bsps/shared/dev/display/disp_hcms29xx.c 
b/bsps/shared/dev/display/disp_hcms29xx.c
index 5730b36ea9..fb88f66343 100644
--- a/bsps/shared/dev/display/disp_hcms29xx.c
+++ b/bsps/shared/dev/display/disp_hcms29xx.c
@@ -589,10 +589,9 @@ static rtems_task disp_hcms29xx_update_task
                                    RTEMS_WAIT,RTEMS_NO_TIMEOUT);
        }
        if (rc == RTEMS_SUCCESSFUL) {
-       strncpy(softc_ptr->disp_param.disp_buffer,
+       strlcpy(softc_ptr->disp_param.disp_buffer,
                softc_ptr->disp_param.trns_buffer,
                sizeof(softc_ptr->disp_param.disp_buffer));
-       
softc_ptr->disp_param.disp_buffer[sizeof(softc_ptr->disp_param.disp_buffer)-1] 
= '\0';
        softc_ptr->disp_param.disp_buf_cnt =
          (int) strlen(softc_ptr->disp_param.disp_buffer);
        }
Please check what strlcpy() returns and use it to get rid of the strlen() call.
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to