Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-13 06:21:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-13 06:21:27 +0300
commit867fc4b463ef39ea16103f18f332c3d259624d29 (patch)
tree7d20c416241afb7b878b767a9955e284d3cddbe2 /source/blender/blenfont
parent9e03a0d4762b4734fe7ccb20e03b4a3c8f939620 (diff)
enforce string limits (reported by pedantic checking tools & some developers).
mostly replace strcpy with BLI_strncpy and multiple strcat's with a BLI_snprintf(). also fix possible crash if CWD isnt available.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf_dir.c16
-rw-r--r--source/blender/blenfont/intern/blf_lang.c20
2 files changed, 13 insertions, 23 deletions
diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c
index 1eb7597fa54..6bee7b38537 100644
--- a/source/blender/blenfont/intern/blf_dir.c
+++ b/source/blender/blenfont/intern/blf_dir.c
@@ -125,20 +125,16 @@ char *blf_dir_search(const char *file)
{
DirBLF *dir;
char full_path[FILE_MAXDIR+FILE_MAXFILE];
- char *s;
-
- dir= global_font_dir.first;
- s= NULL;
- while (dir) {
- BLI_join_dirfile(full_path, dir->path, file);
+ char *s= NULL;
+
+ for(dir=global_font_dir.first; dir; dir= dir->next) {
+ BLI_join_dirfile(full_path, sizeof(full_path), dir->path, file);
if (BLI_exist(full_path)) {
- s= (char *)MEM_mallocN(strlen(full_path)+1,"blf_dir_search");
- strcpy(s, full_path);
+ s= BLI_strdup(full_path);
break;
}
- dir= dir->next;
}
-
+
if (!s) {
/* check the current directory, why not ? */
if (BLI_exist(file))
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c
index 8a929e1ebf7..ebfb7f4eb65 100644
--- a/source/blender/blenfont/intern/blf_lang.c
+++ b/source/blender/blenfont/intern/blf_lang.c
@@ -38,11 +38,11 @@
#include "DNA_listBase.h"
#include "DNA_vec_types.h"
+#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
#include "BLI_linklist.h" /* linknode */
#include "BLI_string.h"
+#include "BLI_path_util.h"
#ifdef __APPLE__
@@ -79,20 +79,14 @@ void BLF_lang_set(const char *str)
#else
char *locreturn= setlocale(LC_ALL, str);
if (locreturn == NULL) {
- char *lang;
-
- lang= (char*)malloc(sizeof(char)*(strlen(str)+7));
-
- lang[0]= '\0';
- strcat(lang, str);
- strcat(lang, ".UTF-8");
+ char *lang= BLI_sprintfN("%s.UTF-8", str);
locreturn= setlocale(LC_ALL, lang);
if (locreturn == NULL) {
printf("could not change language to %s nor %s\n", str, lang);
}
- free(lang);
+ MEM_freeN(lang);
}
setlocale(LC_NUMERIC, "C");
@@ -100,12 +94,12 @@ void BLF_lang_set(const char *str)
textdomain(DOMAIN_NAME);
bindtextdomain(DOMAIN_NAME, global_messagepath);
/* bind_textdomain_codeset(DOMAIN_NAME, global_encoding_name); */
- strcpy(global_language, str);
+ BLI_strncpy(global_language, str, sizeof(global_language));
}
void BLF_lang_encoding(const char *str)
{
- strcpy(global_encoding_name, str);
+ BLI_strncpy(global_encoding_name, str, sizeof(global_encoding_name));
/* bind_textdomain_codeset(DOMAIN_NAME, encoding_name); */
}
@@ -116,7 +110,7 @@ void BLF_lang_init(void)
return;
}
-void BLF_lang_encoding(char *str)
+void BLF_lang_encoding(const char *str)
{
(void)str;
return;