jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=151eeacec8c21f203e9d17718ac132d7f56e5155

commit 151eeacec8c21f203e9d17718ac132d7f56e5155
Author: Jean-Philippe Andre <[email protected]>
Date:   Fri Nov 28 11:21:43 2014 +0900

    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.
---
 .../evas/engines/gl_common/evas_gl_api_ext.c        | 21 ++++++++++++++-------
 1 file 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)
          "GL_EXT_read_format_bgra "
          "GL_EXT_texture_format_BGRA8888 "
          "GL_EXT_texture_type_2_10_10_10_REV ";
-   strcpy(_gl_ext_string, desktop_exts);
-   strcpy(_gl_ext_string_official, desktop_exts);
+   strncpy(_gl_ext_string, desktop_exts, MAX_EXTENSION_STRING_BUFFER);
+   strncpy(_gl_ext_string_official, desktop_exts, MAX_EXTENSION_STRING_BUFFER);
 #endif
 
    
/////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -373,7 +373,11 @@ re->info->info.screen);
    // Extension HEADER
    
/////////////////////////////////////////////////////////////////////////////////////////////////////
 #define _EVASGL_EXT_BEGIN(name) \
-     if (_gl_ext_support_##name != 0) { strcat(_gl_ext_string, #name" "); 
_curext_supported = 1; } \
+     if (_gl_ext_support_##name != 0) \
+       { \
+          strncat(_gl_ext_string, #name" ", MAX_EXTENSION_STRING_BUFFER); \
+          _curext_supported = 1; \
+       } \
      else _curext_supported = 0;
 
 #define _EVASGL_EXT_END()
@@ -381,10 +385,10 @@ re->info->info.screen);
 #define _EVASGL_EXT_DISCARD_SUPPORT()
 #define _EVASGL_EXT_DRVNAME(name) \
    if (_curext_supported) \
-   { \
-      strcat(_gl_ext_string, #name" "); \
-      strcat(_gl_ext_string_official, #name" "); \
-   }
+     { \
+        strncat(_gl_ext_string, #name" ", MAX_EXTENSION_STRING_BUFFER); \
+        strncat(_gl_ext_string_official, #name" ", 
MAX_EXTENSION_STRING_BUFFER); \
+     }
 #define _EVASGL_EXT_DRVNAME_DESKTOP(deskname)
 #define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param)
 #define _EVASGL_EXT_FUNCTION_END()
@@ -405,6 +409,9 @@ re->info->info.screen);
 #undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
    
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
+   _gl_ext_string[MAX_EXTENSION_STRING_BUFFER - 1] = '\0';
+   _gl_ext_string_official[MAX_EXTENSION_STRING_BUFFER - 1] = '\0';
+
   _evgl_api_ext_status = 1;
    return EINA_TRUE;
 }

-- 


Reply via email to