Skip to content

A null pointer exception occurs when the nc_recv_reply function is used #595

@sicongPang

Description

@sicongPang

hello
When using libnetconf2 v3.7.10 as the client, I use the nc_recv_reply function to receive remote RPC messages.
When I construct an abnormal message to be returned from the remote end, this function throws a SIGSEGV exception signal.

According to the preliminary analysis, the abnormal point is found in the following code of the recv_reply function:
/* parsing error */
ERR(session, "Received an invalid message (%s).", ly_err_last(LYD_CTX(op))->msg);

Compared with the code of libnetconf2 v2, the code for printing parameters here is changed from "ly_errmsg(LYD_CTX(op))" to "ly_err_last(LYD_CTX(op))->msg".
I checked the code of libyang 3.13.5 and found that the ly_err_last function may return NULL. If the msg pointer is now used, an exception will occur.

Why is the libyang macro definition ly_errmsg not used here? There is a null check here, so this exception will not occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:bugBug description.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions