[rtems commit] libdl: Fix potential overwrite of dest buffer

Sebastian Huber sebh at rtems.org
Thu Feb 8 08:18:04 UTC 2018


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jan  3 16:09:05 2018 +0100

libdl: Fix potential overwrite of dest buffer

Update #2843.

---

 cpukit/libdl/rap.c       | 2 +-
 cpukit/libdl/rtl-error.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpukit/libdl/rap.c b/cpukit/libdl/rap.c
index c512571..bb42072 100644
--- a/cpukit/libdl/rap.c
+++ b/cpukit/libdl/rap.c
@@ -419,7 +419,7 @@ rtems_rap_get_error (char* message, size_t max_message)
 {
   rtems_rap_data_t* rap = rtems_rap_lock ();
   int               last_errno = rap->last_errno;
-  strncpy (message, rap->last_error, sizeof (rap->last_error));
+  strlcpy (message, rap->last_error, max_message);
   rtems_rap_unlock ();
   return last_errno;
 }
diff --git a/cpukit/libdl/rtl-error.c b/cpukit/libdl/rtl-error.c
index 449beb5..5638b88 100644
--- a/cpukit/libdl/rtl-error.c
+++ b/cpukit/libdl/rtl-error.c
@@ -44,7 +44,7 @@ rtems_rtl_get_error (char* message, size_t max_message)
   if (rtl != NULL)
   {
     int last_errno = rtl->last_errno;
-    strncpy (message, rtl->last_error, sizeof (rtl->last_error));
+    strlcpy (message, rtl->last_error, max_message);
     rtems_rtl_unlock ();
     return last_errno;
   }




More information about the vc mailing list