Skip to content

[BUG]Potential NPD in listDup due to unchecked listGetIterator return value #15007

@NOVAZHOU2

Description

@NOVAZHOU2

Description:
A null pointer dereference (NPD) vulnerability was identified in src/adlist.c. The function listDup fails to verify the success of iterator allocation before passing it to listNext.

Vulnerability Detail:

Source: listGetIterator invokes zmalloc. Under low-memory conditions, it may return NULL.

Propagation: listDup receives this NULL pointer and immediately calls listNext(iter).

Sink: Inside listNext, the dereference iter->next occurs without any safety check, leading to a process crash.

Steps to Reproduce (PoC):
This bug can be theoretically triggered by simulating a zmalloc failure (e.g., using a memory-limited environment or a custom allocator that fails on a specific call).

Suggested Fix:
Add a null check after iterator acquisition in listDup:

iter = listGetIterator(orig, AL_START_HEAD);
if (iter == NULL) return NULL; // Handle allocation failure

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