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

Strncpy() is unsafe if the terminating NUL is missing. Replace it by the
safer strlcpy() and fix the string truncation warning,since the
strlcpy() function returns the total length of the string it tried to
create,that means: the length of src.
---
 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);
       }
-- 
2.26.2

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel
  • [PATCH] display/disp_hcms29xx: Fix string truncation wa... Aschref Ben-Thabet

Reply via email to