[Pkg-e-commits] [SCM] Enlightenment DR17 file chunk reading/writing library branch, upstream-vcs, updated. a69a05397f2e0ea58ef72d66be1b9700c8b707cf

cedric cedric at alioth.debian.org
Tue May 20 11:47:57 UTC 2008


The following commit has been merged in the upstream-vcs branch:
commit 7d960dce0aec1e89cf316fb4776032aedde805fd
Author: cedric <cedric>
Date:   Mon May 19 15:25:46 2008 +0000

    Remove all use of strcpy as we already know the length.

diff --git a/src/lib/eet_data.c b/src/lib/eet_data.c
index 4e35a75..6a96172 100644
--- a/src/lib/eet_data.c
+++ b/src/lib/eet_data.c
@@ -417,7 +417,7 @@ eet_data_put_string(Eet_Dictionary *ed, const void *src, int *size_ret)
    len = strlen(s);
    d = malloc(len + 1);
    if (!d) return NULL;
-   strcpy(d, s);
+   memcpy(d, s, len + 1);
    *size_ret = len + 1;
    return d;
 }
@@ -526,7 +526,7 @@ eet_data_put_float(Eet_Dictionary *ed, const void *src, int *size_ret)
         len = strlen(buf);
         d = malloc(len + 1);
         if (!d) return NULL;
-        strcpy(d, buf);
+	memcpy(d, buf, len + 1);
         *size_ret = len + 1;
         return d;
      }
@@ -589,7 +589,7 @@ eet_data_put_double(Eet_Dictionary *ed, const void *src, int *size_ret)
         len = strlen(buf);
         d = malloc(len + 1);
         if (!d) return NULL;
-        strcpy(d, buf);
+	memcpy(d, buf, len + 1);
         *size_ret = len + 1;
 
         return d;
diff --git a/src/lib/eet_lib.c b/src/lib/eet_lib.c
index 8e47693..20d511f 100644
--- a/src/lib/eet_lib.c
+++ b/src/lib/eet_lib.c
@@ -1134,6 +1134,7 @@ eet_open(const char *file, Eet_File_Mode mode)
 {
    FILE         *fp;
    Eet_File	*ef;
+   int		 file_len;
    struct stat	 file_stat;
 
    if (!file)
@@ -1214,8 +1215,10 @@ eet_open(const char *file, Eet_File_Mode mode)
 	return ef;
      }
 
+   file_len = strlen(file) + 1;
+
    /* Allocate struct for eet file and have it zero'd out */
-   ef = malloc(sizeof(Eet_File) + strlen(file) + 1);
+   ef = malloc(sizeof(Eet_File) + file_len);
    if (!ef)
      return NULL;
 
@@ -1223,7 +1226,7 @@ eet_open(const char *file, Eet_File_Mode mode)
    ef->fp = fp;
    ef->readfp = NULL;
    ef->path = ((char *)ef) + sizeof(Eet_File);
-   strcpy(ef->path, file);
+   memcpy(ef->path, file, file_len);
    ef->magic = EET_MAGIC_FILE;
    ef->references = 1;
    ef->mode = mode;

-- 
Enlightenment DR17 file chunk reading/writing library



More information about the Pkg-e-commits mailing list