[rtems commit] disp_hcms29xx: Fix string truncation warning

Sebastian Huber sebh at rtems.org
Sat Oct 10 13:16:00 UTC 2020


Module:    rtems
Branch:    master
Commit:    f28a6defd136ab05473700c7d34845e42a45adf4
Changeset: http://git.rtems.org/rtems/commit/?id=f28a6defd136ab05473700c7d34845e42a45adf4

Author:    Frank Kühndel <frank.kuehndel at embedded-brains.de>
Date:      Mon Oct  5 16:28:24 2020 +0200

disp_hcms29xx: Fix string truncation warning

The strlcpy() function ensures there is always a NUL character
at the end of the string. Hence it is safer as strncpy() and it avoids the
compiler warning

---

 bsps/shared/dev/display/disp_hcms29xx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/bsps/shared/dev/display/disp_hcms29xx.c b/bsps/shared/dev/display/disp_hcms29xx.c
index 5730b36..740aa56 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,
-		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';
+        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_buf_cnt =
 	  (int) strlen(softc_ptr->disp_param.disp_buffer);
       }



More information about the vc mailing list