Skip to content

[BUG] #8165

@lycronaldo

Description

@lycronaldo

Describe the bug

In src/anet.c, line 503, _anetTcpServer will call anetV6Only. If it failed in setsockopt at line 471, it will close the socket and goto label error at line 513 without change socket to -1. Suppose that we do not support IPV6 Protocol, and we create a socket, then it will be closed. And at the "error" label, it will be closed twice and return a errno EBADF, which will cause failure to create any tcp server.

To reproduce

  1. Use lwip (https://git.savannah.nongnu.org/cgit/lwip.git, version 2.1.2 released) as the Internet support.
  2. Set LWIP_IPV6 macro to 0
  3. Compile the redis and run redis-server
  4. We can observe that redis cannot create any http server.

Expected behavior

The socket should be set to -1 to avoid double close.

Additional information

It can simply resolved by adding "s = -1" in the conditional branch at line 504.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions