[PATCH] imfs: use safe string functions

Gedare Bloom gedare at rtems.org
Thu Sep 5 18:45:03 UTC 2013


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);
     }
     /*
-- 
1.7.1




More information about the devel mailing list