summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-11-28 11:21:43 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-11-28 16:26:49 +0900
commit151eeacec8c21f203e9d17718ac132d7f56e5155 (patch)
tree56e8b53b04a358c4ebec49f27bbe31271d73cc0b
parent47ec70c003b4393f95dfedf385aeb498ed1254ed (diff)
Evas GL: Use strncat and strncpy for safety
Fixes Coverity reports: - CID 1256183 Coverity was a bit stupid there. It knows the size of both strings and complained about unsafe strcpy. It should have complained about unsafe strcat instead.
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_ext.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
index b696d74..576718f 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
@@ -268,8 +268,8 @@ evgl_api_ext_init(void *getproc, const char *glueexts)
268 "GL_EXT_read_format_bgra " 268 "GL_EXT_read_format_bgra "
269 "GL_EXT_texture_format_BGRA8888 " 269 "GL_EXT_texture_format_BGRA8888 "
270 "GL_EXT_texture_type_2_10_10_10_REV "; 270 "GL_EXT_texture_type_2_10_10_10_REV ";
271 strcpy(_gl_ext_string, desktop_exts); 271 strncpy(_gl_ext_string, desktop_exts, MAX_EXTENSION_STRING_BUFFER);
272 strcpy(_gl_ext_string_official, desktop_exts); 272 strncpy(_gl_ext_string_official, desktop_exts, MAX_EXTENSION_STRING_BUFFER);
273#endif 273#endif
274 274
275 ///////////////////////////////////////////////////////////////////////////////////////////////////// 275 /////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -373,7 +373,11 @@ re->info->info.screen);
373 // Extension HEADER 373 // Extension HEADER
374 ///////////////////////////////////////////////////////////////////////////////////////////////////// 374 /////////////////////////////////////////////////////////////////////////////////////////////////////
375#define _EVASGL_EXT_BEGIN(name) \ 375#define _EVASGL_EXT_BEGIN(name) \
376 if (_gl_ext_support_##name != 0) { strcat(_gl_ext_string, #name" "); _curext_supported = 1; } \ 376 if (_gl_ext_support_##name != 0) \
377 { \
378 strncat(_gl_ext_string, #name" ", MAX_EXTENSION_STRING_BUFFER); \
379 _curext_supported = 1; \
380 } \
377 else _curext_supported = 0; 381 else _curext_supported = 0;
378 382
379#define _EVASGL_EXT_END() 383#define _EVASGL_EXT_END()
@@ -381,10 +385,10 @@ re->info->info.screen);
381#define _EVASGL_EXT_DISCARD_SUPPORT() 385#define _EVASGL_EXT_DISCARD_SUPPORT()
382#define _EVASGL_EXT_DRVNAME(name) \ 386#define _EVASGL_EXT_DRVNAME(name) \
383 if (_curext_supported) \ 387 if (_curext_supported) \
384 { \ 388 { \
385 strcat(_gl_ext_string, #name" "); \ 389 strncat(_gl_ext_string, #name" ", MAX_EXTENSION_STRING_BUFFER); \
386 strcat(_gl_ext_string_official, #name" "); \ 390 strncat(_gl_ext_string_official, #name" ", MAX_EXTENSION_STRING_BUFFER); \
387 } 391 }
388#define _EVASGL_EXT_DRVNAME_DESKTOP(deskname) 392#define _EVASGL_EXT_DRVNAME_DESKTOP(deskname)
389#define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param) 393#define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param)
390#define _EVASGL_EXT_FUNCTION_END() 394#define _EVASGL_EXT_FUNCTION_END()
@@ -405,6 +409,9 @@ re->info->info.screen);
405#undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR 409#undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
406 ///////////////////////////////////////////////////////////////////////////////////////////////////// 410 /////////////////////////////////////////////////////////////////////////////////////////////////////
407 411
412 _gl_ext_string[MAX_EXTENSION_STRING_BUFFER - 1] = '\0';
413 _gl_ext_string_official[MAX_EXTENSION_STRING_BUFFER - 1] = '\0';
414
408 _evgl_api_ext_status = 1; 415 _evgl_api_ext_status = 1;
409 return EINA_TRUE; 416 return EINA_TRUE;
410} 417}