summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-13 16:27:04 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-13 21:26:05 +0900
commit8cdef1831c2cbdad9fc3bb8b03601d76ebe15a94 (patch)
treee3283e67660a50748cbe736a0068a514ab654dfd
parentf374815a3e66a389bf2495fadbc82eec0e6f586b (diff)
ecore-con - fix possible unterminated buffers
this should fix CID 1039725 and CID 1039724
-rw-r--r--src/lib/ecore_con/ecore_con_local.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c
index df86334c50..54dde177bc 100644
--- a/src/lib/ecore_con/ecore_con_local.c
+++ b/src/lib/ecore_con/ecore_con_local.c
@@ -91,7 +91,10 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
91 if (svr->port < 0) 91 if (svr->port < 0)
92 { 92 {
93 if (svr->name[0] == '/') 93 if (svr->name[0] == '/')
94 strncpy(buf, svr->name, sizeof(buf)); 94 {
95 strncpy(buf, svr->name, sizeof(buf) - 1);
96 buf[sizeof(buf) - 1] = 0;
97 }
95 else 98 else
96 snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s", svr->name); 99 snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s", svr->name);
97 } 100 }
@@ -108,8 +111,10 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
108 } 111 }
109 } 112 }
110 else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) 113 else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT)
111 strncpy(buf, svr->name, 114 {
112 sizeof(buf)); 115 strncpy(buf, svr->name, sizeof(buf) - 1);
116 buf[sizeof(buf) - 1] = 0;
117 }
113 118
114 svr->fd = socket(AF_UNIX, SOCK_STREAM, 0); 119 svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
115 if (svr->fd < 0) 120 if (svr->fd < 0)
@@ -251,8 +256,10 @@ ecore_con_local_listen(
251 svr->port); 256 svr->port);
252 } 257 }
253 else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) 258 else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT)
254 strncpy(buf, svr->name, 259 {
255 sizeof(buf)); 260 strncpy(buf, svr->name, sizeof(buf) - 1);
261 buf[sizeof(buf) - 1] = 0;
262 }
256 263
257 pmode = umask(mask); 264 pmode = umask(mask);
258start: 265start: