[rtems commit] libdl/archive: Fix the config file string index while removing tailing white space.

Chris Johns chrisj at rtems.org
Tue Feb 19 22:09:43 UTC 2019


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

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Feb 18 12:18:50 2019 +1100

libdl/archive: Fix the config file string index while removing tailing white space.

Coverity issue 1442540

Updates #3686

---

 cpukit/include/rtems/rtl/rtl-archive.h | 2 +-
 cpukit/libdl/rtl-archive.c             | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cpukit/include/rtems/rtl/rtl-archive.h b/cpukit/include/rtems/rtl/rtl-archive.h
index 1fe3aae..8aa163e 100644
--- a/cpukit/include/rtems/rtl/rtl-archive.h
+++ b/cpukit/include/rtems/rtl/rtl-archive.h
@@ -103,7 +103,7 @@ typedef struct rtems_rtl_archives
   const char*         config_name;    /**< Config file name. */
   time_t              config_mtime;   /**< Config last modified time. */
   size_t              config_length;  /**< Length the config data. */
-  const char*         config;         /**< Config file contents. */
+  char*               config;         /**< Config file contents. */
   rtems_chain_control archives;       /**< The located archives. */
 } rtems_rtl_archives;
 
diff --git a/cpukit/libdl/rtl-archive.c b/cpukit/libdl/rtl-archive.c
index faa6616..8490b4b 100644
--- a/cpukit/libdl/rtl-archive.c
+++ b/cpukit/libdl/rtl-archive.c
@@ -528,9 +528,9 @@ rtems_rtl_archives_load_config (rtems_rtl_archives* archives)
           ++b;
         }
         b = ls - 1;
-        while (b > 0 && isspace (s[b]))
+        while (b > 0 && isspace (s[r + b]))
         {
-          s[b] = '\0';
+          s[r + b] = '\0';
           --b;
         }
         r += ls;




More information about the vc mailing list