Skip to content

VSOCK socket client would almost always fail #576

@solokacher

Description

@solokacher

Describe the bug

Function s_update_local_endpoint(struct aws_socket *socket) defined at
source/posix/socket.c#L273 has the following logic:

        /* VSOCK port is 32bit, but aws_socket_endpoint.port is only 16bit.
         * Hopefully this isn't an issue, since users can only pass in 16bit values.
         * But if it becomes an issue, we'll need to make aws_socket_endpoint more flexible */
        if (s->svm_port > UINT16_MAX) {
            AWS_LOGF_ERROR(
                AWS_LS_IO_SOCKET,
                "id=%p fd=%d: aws_socket_endpoint can't deal with VSOCK port > UINT16_MAX",
                (void *)socket,
                socket->io_handle.data.fd);
            return aws_raise_error(AWS_IO_SOCKET_INVALID_ADDRESS);
        }
        tmp_endpoint.port = (uint16_t)s->svm_port;

When it is used as a client, it would almost always fail, as the ephemeral port grabbed from the system is likely be large number. How did we test this code?

Expected Behavior

aws_socket_connect() should succeed

Current Behavior

Failure with aws_socket_endpoint can't deal with VSOCK port > UINT16_MAX

Reproduction Steps

Create a client and connect to any VSOCK address

Possible Solution

use 32 bit port number

Additional Information/Context

No response

aws-c-io version used

version containing df07e42

Compiler and version used

clang14

Operating System and version

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions