// If SOCK_CLOEXEC exists then we don't need to call the following
if (SOCK_CLOEXEC == 0)
{
- if (FD_CLOEXEC)
+ if (FD_CLOEXEC != 0)
{
int flags;
do
do {
int type= SOCK_STREAM;
- if (SOCK_CLOEXEC)
+ if (SOCK_CLOEXEC != 0)
{
type|= SOCK_CLOEXEC;
}
- if (SOCK_NONBLOCK)
+ if (SOCK_NONBLOCK != 0)
{
type|= SOCK_NONBLOCK;
}
memset(&servAddr, 0, sizeof (struct sockaddr_un));
servAddr.sun_family= AF_UNIX;
- strncpy(servAddr.sun_path, server->hostname(), sizeof(servAddr.sun_path)); /* Copy filename */
+ if (strlen(server->hostname()) >= sizeof(servAddr.sun_path)) {
+ return memcached_set_error(*server, MEMCACHED_UNIX_SOCKET_PATH_TOO_BIG, MEMCACHED_AT);
+ }
+ strncpy(servAddr.sun_path, server->hostname(), sizeof(servAddr.sun_path)-1); /* Copy filename */
if (connect(server->fd, (struct sockaddr *)&servAddr, sizeof(servAddr)) == -1)
{
}
int type= server->address_info_next->ai_socktype;
- if (SOCK_CLOEXEC)
+ if (SOCK_CLOEXEC != 0)
{
type|= SOCK_CLOEXEC;
}
- if (SOCK_NONBLOCK)
+ if (SOCK_NONBLOCK != 0)
{
type|= SOCK_NONBLOCK;
}