Skip to content

Handle_LEAK in /deps/hiredis/net.c:124 ( v. 8.0.3 ) #1309

@guschin058

Description

@guschin058

Handle 's' is created at net.c:124 by calling function 'socket' and lost at net.c:131.
The redisCreateSocket() function creates a socket descriptor, but does not close it in the error handling path when redisSetReuseAddr() returns REDIS_ERR. This creates a resource leak in which socket descriptors remain open indefinitely, potentially leading to EMFILE errors (too many open files) and system instability.
Line 124 https://github.com/redis/redis/blob/8.0.3/deps/hiredis/net.c#L124

static int redisCreateSocket(redisContext *c, int type) {
    redisFD s;
    if ((s = socket(type, SOCK_STREAM, 0)) == REDIS_INVALID_FD) {
        __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
        return REDIS_ERR;
    }
    c->fd = s;
    if (type == AF_INET) {
        if (redisSetReuseAddr(c) == REDIS_ERR) {
            return REDIS_ERR;
        }
    }
    return REDIS_OK;
}

Found Linux Verification Center ( linuxtesting.org ) with SVACE
Reporter: Gushchin Egor ( guschin058@yandex.ru )

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