Skip to content

Error paths in handle_peer_spoke(…) in lightningd/peer_control.c dereference an uninitialized pointer #8849

@whitslack

Description

@whitslack

The local variable error is declared to be of a pointer type with no initialization:

const u8 *error;

Several error paths, upon failure to create a socket pair, jump to the label send_error without initializing error.

pfd = sockpair(tmpctx, channel, &other_fd, &error);
if (!pfd)
goto send_error;

pfd = sockpair(tmpctx, channel, &other_fd, &error);
if (!pfd)
goto send_error;

pfd = sockpair(tmpctx, channel, &other_fd, &error);
if (!pfd)
goto send_error;

pfd = sockpair(tmpctx, channel, &other_fd, &error);
if (!pfd)
goto send_error;

The code at send_error passes error as an argument to both tal_hex and towire_connectd_peer_send_msg:

send_error:
log_peer_debug(ld->log, &peer->id, "Telling connectd to send error %s",
tal_hex(tmpctx, error));
/* Get connectd to send error and close. */
subd_send_msg(ld->connectd,
take(towire_connectd_peer_send_msg(NULL, &peer->id,
peer->connectd_counter,
error)));

The consequence is likely to be a segfault when a socket pair cannot be created.

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