Azure/azure-c-shared-utility

Segmentation fault caused by initiate_socket_connection in adapters/socketio_berkeley.c when DNS resolution failed

advantech-edgelink opened this issue · 2 comments

static int initiate_socket_connection(SOCKET_IO_INSTANCE* socket_io_instance)
{
    int result;
    int flags;
    struct addrinfo* addr = NULL;
    struct sockaddr_un addrInfoUn;

    if(socket_io_instance->address_type == ADDRESS_TYPE_IP)
    {
        ...
    }
    else
    {
        ...
    }

    if (socket_io_instance->address_type == ADDRESS_TYPE_IP)
    {
        socket_io_instance->socket = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
    }
    else
    {
        socket_io_instance->socket = socket(AF_UNIX, SOCK_STREAM, 0);
    }
    ...
}

The addr may be NULL when executing socket_io_instance->socket = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);

Thanks for reporting, @advantech-edgelink ! A PR with the fix will come briefly.

Hi @advantech-edgelink, we've merged the PR with the fix, thank you again for reporting! Closing the issue now.