diff options
author | Cedric BAIL <cedric.bail@free.fr> | 2008-05-19 15:25:46 +0000 |
---|---|---|
committer | Cedric BAIL <cedric.bail@free.fr> | 2008-05-19 15:25:46 +0000 |
commit | 4e91c75d6222f31d570122e792b1cfb390b52dea (patch) | |
tree | 93abc8cec9d046ad5b1a953a4917a5133c326679 /src/lib | |
parent | 3be3c3d239f527b7dd49189398a5be250b2fe4ce (diff) | |
download | eet-4e91c75d6222f31d570122e792b1cfb390b52dea.tar.gz |
Remove all use of strcpy as we already know the length.
SVN revision: 34617
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/eet_data.c | 6 | ||||
-rw-r--r-- | src/lib/eet_lib.c | 7 |
2 files changed, 8 insertions, 5 deletions
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; |