From 867fc4b463ef39ea16103f18f332c3d259624d29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Feb 2011 03:21:27 +0000 Subject: 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. --- source/blender/blenkernel/intern/font.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern/font.c') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 1d7ce197cba..9de8af2c981 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -96,13 +96,14 @@ chtoutf8(unsigned long c, char *o) void wcs2utf8s(char *dst, wchar_t *src) { - char ch[5]; + /* NULL terminator not needed */ + char ch[4]; while(*src) { - memset(ch, 0, 5); + memset(ch, 0, sizeof(ch)); chtoutf8(*src++, ch); - strcat(dst, ch); + dst= strncat(dst, ch, sizeof(ch)); } } @@ -363,14 +364,14 @@ VFont *load_vfont(const char *name) struct TmpFont *tmpfnt; if (strcmp(name, FO_BUILTIN_NAME)==0) { - strcpy(filename, name); + BLI_strncpy(filename, name, sizeof(filename)); pf= get_builtin_packedfile(); is_builtin= 1; } else { char dir[FILE_MAXDIR]; - strcpy(dir, name); + BLI_strncpy(dir, name, sizeof(dir)); BLI_splitdirstring(dir, filename); pf= newPackedFile(NULL, name); -- cgit v1.2.3