summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorWonki Kim <wonki_.kim@samsung.com>2019-02-13 04:06:36 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-02-13 16:37:08 -0800
commit1cdedaa33b25b95f5305fb808c20526ced763110 (patch)
tree9f2b0e11d6c05899b351b00caaef9f1126688e1f /src/lib/ecore_con
parent19fcd6e60fdb702ea0db4a9884c4822e624ecde4 (diff)
ecore_con: Fix potentional problems around ecore_con
non-thread safe functions are used like rand(), strerror(). this patch replace them with thread safe one. and also this patch contains a change to fix a memory leak problem. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D7917
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/ecore_con.c6
-rw-r--r--src/lib/ecore_con/ecore_con_legacy.c2
-rw-r--r--src/lib/ecore_con/ecore_con_local.c4
-rw-r--r--src/lib/ecore_con/ecore_con_url.c2
-rw-r--r--src/lib/ecore_con/efl_net_dialer_http.c2
-rw-r--r--src/lib/ecore_con/efl_net_server_fd.c6
-rw-r--r--src/lib/ecore_con/efl_net_server_udp.c9
-rw-r--r--src/lib/ecore_con/efl_net_socket_udp.c2
-rw-r--r--src/lib/ecore_con/efl_net_ssl_ctx-gnutls.c2
-rw-r--r--src/lib/ecore_con/efl_net_ssl_ctx-openssl.c2
10 files changed, 21 insertions, 16 deletions
diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
index 5a305d0..7c6e93e 100644
--- a/src/lib/ecore_con/ecore_con.c
+++ b/src/lib/ecore_con/ecore_con.c
@@ -201,7 +201,7 @@ efl_net_unix_fmt(char *buf, size_t buflen, SOCKET fd, const struct sockaddr_un *
201 int r = snprintf(buf, buflen, "unnamed:" SOCKET_FMT, fd); 201 int r = snprintf(buf, buflen, "unnamed:" SOCKET_FMT, fd);
202 if (r < 0) 202 if (r < 0)
203 { 203 {
204 ERR("snprintf(): %s", strerror(errno)); 204 ERR("snprintf(): %s", eina_error_msg_get(errno));
205 return EINA_FALSE; 205 return EINA_FALSE;
206 } 206 }
207 else if ((size_t)r > buflen) 207 else if ((size_t)r > buflen)
@@ -330,7 +330,7 @@ efl_net_ip_port_fmt(char *buf, size_t buflen, const struct sockaddr *addr)
330 if (!inet_ntop(addr->sa_family, mem, p, sizeof(p))) 330 if (!inet_ntop(addr->sa_family, mem, p, sizeof(p)))
331 { 331 {
332 ERR("inet_ntop(%d, %p, %p, %zd): %s", 332 ERR("inet_ntop(%d, %p, %p, %zd): %s",
333 addr->sa_family, mem, p, sizeof(p), strerror(errno)); 333 addr->sa_family, mem, p, sizeof(p), eina_error_msg_get(errno));
334 return EINA_FALSE; 334 return EINA_FALSE;
335 } 335 }
336 336
@@ -341,7 +341,7 @@ efl_net_ip_port_fmt(char *buf, size_t buflen, const struct sockaddr *addr)
341 341
342 if (r < 0) 342 if (r < 0)
343 { 343 {
344 ERR("could not snprintf(): %s", strerror(errno)); 344 ERR("could not snprintf(): %s", eina_error_msg_get(errno));
345 return EINA_FALSE; 345 return EINA_FALSE;
346 } 346 }
347 else if ((size_t)r > buflen) 347 else if ((size_t)r > buflen)
diff --git a/src/lib/ecore_con/ecore_con_legacy.c b/src/lib/ecore_con/ecore_con_legacy.c
index 1ac6c2a..0e241b7 100644
--- a/src/lib/ecore_con/ecore_con_legacy.c
+++ b/src/lib/ecore_con/ecore_con_legacy.c
@@ -2659,7 +2659,7 @@ _ecore_con_lookup_done_cb(void *data, const char *host, const char *port EINA_UN
2659 2659
2660 if (!inet_ntop(result->ai_family, mem, ip, sizeof(ip))) 2660 if (!inet_ntop(result->ai_family, mem, ip, sizeof(ip)))
2661 { 2661 {
2662 ERR("could not convert IP to string: %s", strerror(errno)); 2662 ERR("could not convert IP to string: %s", eina_error_msg_get(errno));
2663 goto end; 2663 goto end;
2664 } 2664 }
2665 ctx->cb(result->ai_canonname, ip, result->ai_addr, result->ai_addrlen, (void *)ctx->data); 2665 ctx->cb(result->ai_canonname, ip, result->ai_addr, result->ai_addrlen, (void *)ctx->data);
diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c
index b356883..e91819e 100644
--- a/src/lib/ecore_con/ecore_con_local.c
+++ b/src/lib/ecore_con/ecore_con_local.c
@@ -127,7 +127,7 @@ _ecore_con_local_mkpath(const char *path, mode_t mode)
127 { 127 {
128 if (errno != EEXIST) 128 if (errno != EEXIST)
129 { 129 {
130 ERR("could not create parent directory '%s' of path '%s': %s", d, path, strerror(errno)); 130 ERR("could not create parent directory '%s' of path '%s': %s", d, path, eina_error_msg_get(errno));
131 goto end; 131 goto end;
132 } 132 }
133 } 133 }
@@ -138,7 +138,7 @@ _ecore_con_local_mkpath(const char *path, mode_t mode)
138 if (mkdir(d, mode) != 0) 138 if (mkdir(d, mode) != 0)
139 { 139 {
140 if (errno != EEXIST) 140 if (errno != EEXIST)
141 ERR("could not create parent directory '%s' of path '%s': %s", d, path, strerror(errno)); 141 ERR("could not create parent directory '%s' of path '%s': %s", d, path, eina_error_msg_get(errno));
142 else 142 else
143 { 143 {
144 struct stat st; 144 struct stat st;
diff --git a/src/lib/ecore_con/ecore_con_url.c b/src/lib/ecore_con/ecore_con_url.c
index dd8d249..5f94ebf 100644
--- a/src/lib/ecore_con/ecore_con_url.c
+++ b/src/lib/ecore_con/ecore_con_url.c
@@ -425,7 +425,7 @@ _ecore_con_url_dialer_can_read_changed(void *data, const Efl_Event *event EINA_U
425 ssize_t r = write(url_con->write_fd, slice.bytes, slice.len); 425 ssize_t r = write(url_con->write_fd, slice.bytes, slice.len);
426 if (r == -1) 426 if (r == -1)
427 { 427 {
428 ERR("Could not write to fd=%d: %s", url_con->write_fd, strerror(errno)); 428 ERR("Could not write to fd=%d: %s", url_con->write_fd, eina_error_msg_get(errno));
429 break; 429 break;
430 } 430 }
431 slice.bytes += r; 431 slice.bytes += r;
diff --git a/src/lib/ecore_con/efl_net_dialer_http.c b/src/lib/ecore_con/efl_net_dialer_http.c
index 5378851..20f3156 100644
--- a/src/lib/ecore_con/efl_net_dialer_http.c
+++ b/src/lib/ecore_con/efl_net_dialer_http.c
@@ -1796,7 +1796,7 @@ _efl_net_dialer_http_efl_io_closer_close_on_exec_set(Eo *o EINA_UNUSED, Efl_Net_
1796 1796
1797 if (!eina_file_close_on_exec(pd->fd, close_on_exec)) 1797 if (!eina_file_close_on_exec(pd->fd, close_on_exec))
1798 { 1798 {
1799 ERR("fcntl(" SOCKET_FMT ", F_SETFD): %s", pd->fd, strerror(errno)); 1799 ERR("fcntl(" SOCKET_FMT ", F_SETFD): %s", pd->fd, eina_error_msg_get(errno));
1800 pd->close_on_exec = old; 1800 pd->close_on_exec = old;
1801 return EINA_FALSE; 1801 return EINA_FALSE;
1802 } 1802 }
diff --git a/src/lib/ecore_con/efl_net_server_fd.c b/src/lib/ecore_con/efl_net_server_fd.c
index 8a49340..28626b0 100644
--- a/src/lib/ecore_con/efl_net_server_fd.c
+++ b/src/lib/ecore_con/efl_net_server_fd.c
@@ -54,7 +54,7 @@ efl_net_accept4(SOCKET fd, struct sockaddr *addr, socklen_t *addrlen, Eina_Bool
54 if (!eina_file_close_on_exec(client, EINA_TRUE)) 54 if (!eina_file_close_on_exec(client, EINA_TRUE))
55 { 55 {
56 int errno_bkp = errno; 56 int errno_bkp = errno;
57 ERR("fcntl(" SOCKET_FMT ", F_SETFD, FD_CLOEXEC): %s", client, strerror(errno)); 57 ERR("fcntl(" SOCKET_FMT ", F_SETFD, FD_CLOEXEC): %s", client, eina_error_msg_get(errno));
58 closesocket(client); 58 closesocket(client);
59 errno = errno_bkp; 59 errno = errno_bkp;
60 return INVALID_SOCKET; 60 return INVALID_SOCKET;
@@ -282,7 +282,7 @@ _efl_net_server_fd_close_on_exec_set(Eo *o, Efl_Net_Server_Fd_Data *pd, Eina_Boo
282 282
283 if (!eina_file_close_on_exec(fd, close_on_exec)) 283 if (!eina_file_close_on_exec(fd, close_on_exec))
284 { 284 {
285 ERR("fcntl(" SOCKET_FMT ", F_SETFD,): %s", fd, strerror(errno)); 285 ERR("fcntl(" SOCKET_FMT ", F_SETFD,): %s", fd, eina_error_msg_get(errno));
286 pd->close_on_exec = old; 286 pd->close_on_exec = old;
287 return EINA_FALSE; 287 return EINA_FALSE;
288 } 288 }
@@ -311,7 +311,7 @@ _efl_net_server_fd_close_on_exec_get(const Eo *o, Efl_Net_Server_Fd_Data *pd)
311 flags = fcntl(fd, F_GETFD); 311 flags = fcntl(fd, F_GETFD);
312 if (flags < 0) 312 if (flags < 0)
313 { 313 {
314 ERR("fcntl(" SOCKET_FMT ", F_GETFD): %s", fd, strerror(errno)); 314 ERR("fcntl(" SOCKET_FMT ", F_GETFD): %s", fd, eina_error_msg_get(errno));
315 return EINA_FALSE; 315 return EINA_FALSE;
316 } 316 }
317 317
diff --git a/src/lib/ecore_con/efl_net_server_udp.c b/src/lib/ecore_con/efl_net_server_udp.c
index ced3e04..50a0c97 100644
--- a/src/lib/ecore_con/efl_net_server_udp.c
+++ b/src/lib/ecore_con/efl_net_server_udp.c
@@ -171,7 +171,7 @@ _efl_net_server_udp_resolved(void *data, const char *host EINA_UNUSED, const cha
171 Eo *o = data; 171 Eo *o = data;
172 Efl_Net_Server_Udp_Data *pd = efl_data_scope_get(o, MY_CLASS); 172 Efl_Net_Server_Udp_Data *pd = efl_data_scope_get(o, MY_CLASS);
173 const struct addrinfo *addr; 173 const struct addrinfo *addr;
174 Eina_Error err; 174 Eina_Error err = EINA_ERROR_NO_ERROR;
175 175
176 pd->resolver = NULL; 176 pd->resolver = NULL;
177 177
@@ -351,6 +351,7 @@ _efl_net_server_udp_efl_net_server_fd_process_incoming_data(Eo *o, Efl_Net_Serve
351 client = eina_hash_find(pd->clients, str); 351 client = eina_hash_find(pd->clients, str);
352 if (client) 352 if (client)
353 { 353 {
354 free(buf);
354 _efl_net_server_udp_client_feed(client, slice); 355 _efl_net_server_udp_client_feed(client, slice);
355 return; 356 return;
356 } 357 }
@@ -393,8 +394,12 @@ _efl_net_server_udp_efl_net_server_fd_process_incoming_data(Eo *o, Efl_Net_Serve
393 efl_event_callback_add(client, EFL_IO_CLOSER_EVENT_CLOSED, _efl_net_server_udp_client_event_closed, o); 394 efl_event_callback_add(client, EFL_IO_CLOSER_EVENT_CLOSED, _efl_net_server_udp_client_event_closed, o);
394 395
395 if (!efl_net_server_client_announce(o, client)) 396 if (!efl_net_server_client_announce(o, client))
396 return; 397 {
398 free(buf);
399 return;
400 }
397 401
402 free(buf);
398 _efl_net_server_udp_client_feed(client, slice); 403 _efl_net_server_udp_client_feed(client, slice);
399} 404}
400 405
diff --git a/src/lib/ecore_con/efl_net_socket_udp.c b/src/lib/ecore_con/efl_net_socket_udp.c
index 29b66f3..67e3f6a 100644
--- a/src/lib/ecore_con/efl_net_socket_udp.c
+++ b/src/lib/ecore_con/efl_net_socket_udp.c
@@ -119,7 +119,7 @@ _efl_net_socket_udp_bind(Eo *o, Efl_Net_Socket_Udp_Data *pd)
119 if (errno) 119 if (errno)
120 { 120 {
121 err = errno; 121 err = errno;
122 ERR("invalid port numer '%s': %s", bport, strerror(errno)); 122 ERR("invalid port numer '%s': %s", bport, eina_error_msg_get(errno));
123 goto error_bind; 123 goto error_bind;
124 } 124 }
125 125
diff --git a/src/lib/ecore_con/efl_net_ssl_ctx-gnutls.c b/src/lib/ecore_con/efl_net_ssl_ctx-gnutls.c
index 7a92a82..cb19808 100644
--- a/src/lib/ecore_con/efl_net_ssl_ctx-gnutls.c
+++ b/src/lib/ecore_con/efl_net_ssl_ctx-gnutls.c
@@ -125,7 +125,7 @@ _efl_net_ssl_ctx_load_lists(Efl_Net_Ssl_Ctx *ctx, Efl_Net_Ssl_Ctx_Config cfg)
125 r = 0; 125 r = 0;
126 if (stat(path, &st) != 0) 126 if (stat(path, &st) != 0)
127 { 127 {
128 ERR("ssl_ctx=%p could not load certificate authorities from '%s': %s", ctx, path, strerror(errno)); 128 ERR("ssl_ctx=%p could not load certificate authorities from '%s': %s", ctx, path, eina_error_msg_get(errno));
129 eina_stringshare_del(path); 129 eina_stringshare_del(path);
130 *cfg.certificate_authorities = eina_list_remove_list(*cfg.certificate_authorities, n); 130 *cfg.certificate_authorities = eina_list_remove_list(*cfg.certificate_authorities, n);
131 continue; 131 continue;
diff --git a/src/lib/ecore_con/efl_net_ssl_ctx-openssl.c b/src/lib/ecore_con/efl_net_ssl_ctx-openssl.c
index 6efba84..d8e4b6e 100644
--- a/src/lib/ecore_con/efl_net_ssl_ctx-openssl.c
+++ b/src/lib/ecore_con/efl_net_ssl_ctx-openssl.c
@@ -196,7 +196,7 @@ _efl_net_ssl_ctx_check_errors();
196 196
197 if (stat(path, &st) != 0) 197 if (stat(path, &st) != 0)
198 { 198 {
199 ERR("ssl_ctx=%p could not load certificate authorities from '%s': %s", ctx, path, strerror(errno)); 199 ERR("ssl_ctx=%p could not load certificate authorities from '%s': %s", ctx, path, eina_error_msg_get(errno));
200 eina_stringshare_del(path); 200 eina_stringshare_del(path);
201 *cfg.certificate_authorities = eina_list_remove_list(*cfg.certificate_authorities, n); 201 *cfg.certificate_authorities = eina_list_remove_list(*cfg.certificate_authorities, n);
202 continue; 202 continue;