ecore-con - fix possible unterminated buffers

this should fix CID 1039725 and CID 1039724
This commit is contained in:
Carsten Haitzler 2013-12-13 16:27:04 +09:00
parent f374815a3e
commit 8cdef1831c
1 changed files with 12 additions and 5 deletions

View File

@ -91,7 +91,10 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
if (svr->port < 0)
{
if (svr->name[0] == '/')
strncpy(buf, svr->name, sizeof(buf));
{
strncpy(buf, svr->name, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
}
else
snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s", svr->name);
}
@ -108,8 +111,10 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
}
}
else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT)
strncpy(buf, svr->name,
sizeof(buf));
{
strncpy(buf, svr->name, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
}
svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (svr->fd < 0)
@ -251,8 +256,10 @@ ecore_con_local_listen(
svr->port);
}
else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT)
strncpy(buf, svr->name,
sizeof(buf));
{
strncpy(buf, svr->name, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
}
pmode = umask(mask);
start: