ecore con - also be paranoid with same nul byte checks in path str

this won't affect the target system which doesn't do abstract sockets
anyway, and it's just unlink "" ... but check if first byte is nul for
an asbtract socket and dont do lock files or unlinking in this case
This commit is contained in:
Carsten Haitzler 2020-02-15 11:56:13 +00:00
parent 0802f4dc95
commit 6a0de945e0
1 changed files with 10 additions and 9 deletions

View File

@ -61,8 +61,6 @@ _efl_net_server_unix_bind_hang_lock_workaround(const char *address, Eina_Bool lo
char *lockfile;
int ret;
if (strncmp(address, "abstract:", strlen("abstract:")) == 0) return -1;
addrlen = strlen(address);
lockfile = malloc(addrlen + 1 + 5);
if (!lockfile) return -1;
@ -189,15 +187,18 @@ _efl_net_server_unix_bind(Eo *o, Efl_Net_Server_Unix_Data *pd)
}
#ifdef BIND_HANG_WORKAROUND
pd->lock_fd = _efl_net_server_unix_bind_hang_lock_workaround
(address, EINA_TRUE, -1);
if (pd->lock_fd < 0)
if (addr.sun_path[0] != '\0')
{
err = EADDRINUSE;
goto error;
pd->lock_fd = _efl_net_server_unix_bind_hang_lock_workaround
(addr.sun_path, EINA_TRUE, -1);
if (pd->lock_fd < 0)
{
err = EADDRINUSE;
goto error;
}
pd->have_lock_fd = EINA_TRUE;
unlink(addr.sun_path);
}
unlink(addr.sun_path);
pd->have_lock_fd = EINA_TRUE;
#endif
r = bind(fd, (struct sockaddr *)&addr, addrlen);
if (r != 0)