[rtems commit] imfs: use safe string functions

Gedare Bloom gedare at rtems.org
Thu Sep 5 19:07:53 UTC 2013


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

Author:    Gedare Bloom <gedare at rtems.org>
Date:      Thu Sep  5 14:44:24 2013 -0400

imfs: use safe string functions

Replace strcpy and strcat with counted variants.

---

 cpukit/libfs/src/imfs/imfs_load_tar.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/cpukit/libfs/src/imfs/imfs_load_tar.c b/cpukit/libfs/src/imfs/imfs_load_tar.c
index abb9f46..fd47ec2 100644
--- a/cpukit/libfs/src/imfs/imfs_load_tar.c
+++ b/cpukit/libfs/src/imfs/imfs_load_tar.c
@@ -100,10 +100,12 @@ int rtems_tarfs_load(
      * - For files, create a file node with special tarfs properties.
      */
     if (linkflag == DIRTYPE) {
-      strcpy(full_filename, mountpoint);
-      if (full_filename[strlen(full_filename)-1] != '/')
+      int len;
+      strncpy(full_filename, mountpoint, 255);
+      if (full_filename[(len=strlen(full_filename))-1] != '/')
         strcat(full_filename, "/");
-      strcat(full_filename, filename);
+      ++len;
+      strncat(full_filename, filename, 256-len-1);
       rv = mkdir(full_filename, S_IRWXU | S_IRWXG | S_IRWXO);
     }
     /*




More information about the vc mailing list