cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=b1f74c615a57115933ba86ca63bc2da7f3d44f0c
commit b1f74c615a57115933ba86ca63bc2da7f3d44f0c Author: Srivardhan Hebbar <[email protected]> Date: Wed Mar 18 15:33:19 2015 +0100 ecore_con: fix ECORE_CON_LOCAL_SYSTEM use with negative port number. Summary: The socket can be created even with negative port number, but in that case the port is ignored so that you can connect to non Ecore_Con based IPC. This patch remove that test to make the client and server match. @fix Bug: While creating ECORE_CON_LOCAL_SYSTEM server and client pair, when the socket name was "test_socket" and port number "-8" (Any negative number). Then while creating listening socket, the code would go to line no 291 and socket is created in tmp by ".ecore_servicetest_socket|-8". When the same is passed to bind then the code would go to line 118 and the socket it would try to bind would be ".ecore_servicetest_socket" !! So the bind would fail. Signed-off-by: Srivardhan Hebbar <[email protected]> Reviewers: cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2186 Signed-off-by: Cedric BAIL <[email protected]> --- src/lib/ecore_con/ecore_con_local.c | 39 ++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c index 2992058..9af5ca5 100644 --- a/src/lib/ecore_con/ecore_con_local.c +++ b/src/lib/ecore_con/ecore_con_local.c @@ -119,14 +119,11 @@ ecore_con_local_connect(Ecore_Con_Server *obj, } else { - if (svr->name[0] == - '/') - snprintf(buf, sizeof(buf), "%s|%i", svr->name, - svr->port); + if (svr->name[0] == '/') + snprintf(buf, sizeof(buf), "%s|%i", svr->name, svr->port); else snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s|%i", - svr->name, - svr->port); + svr->name, svr->port); } } else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) @@ -273,26 +270,24 @@ ecore_con_local_listen( else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM) { mask = 0; - if (svr->name[0] == '/') + if (svr->port < 0) { - if (svr->port >= 0) - snprintf(buf, - sizeof(buf), - "%s|%i", - svr->name, - svr->port); + if (svr->name[0] == '/') + { + strncpy(buf, svr->name, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = 0; + } else - snprintf(buf, - sizeof(buf), - "%s", - svr->name); + snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s", svr->name); } else - snprintf(buf, - sizeof(buf), - "/tmp/.ecore_service|%s|%i", - svr->name, - svr->port); + { + if (svr->name[0] == '/') + snprintf(buf, sizeof(buf), "%s|%i", svr->name, svr->port); + else + snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s|%i", + svr->name, svr->port); + } } else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_ABSTRACT) { --
