Skip to content

session: do not free rpc request external data#66

Closed
rjarry wants to merge 1 commit intoCESNET:develfrom
6WIND:double-free
Closed

session: do not free rpc request external data#66
rjarry wants to merge 1 commit intoCESNET:develfrom
6WIND:double-free

Conversation

@rjarry
Copy link
Copy Markdown
Contributor

@rjarry rjarry commented Jul 9, 2018

When making a generic rpc request:

struct lyd_node *input;
struct nc_reply *reply
struct nc_rpc *rpc;
uint64_t msgid;

input= lyd_new_path(NULL, ctx, "/example:my-rpc/parameter", "value",
                    LYD_ANYDATA_CONSTSTRING, LYD_PATH_OPT_UPDATE);

rpc = nc_rpc_act_generic(input, NC_PARAMTYPE_CONST);
nc_send_rpc(session, rpc, 1000, &msgid);
nc_recv_reply(nc_session, rpc, msgid, 1000, &reply);  /* input is freed by parse_reply */

nc_reply_free(reply);
nc_rpc_free(rpc);
lyd_free_withsiblings(input);  /* double free here */

If the rpc request data was allocated outside of parse_reply, it should not be freed.

Only free it if it was allocated in parse_reply().

When making a generic rpc request:

  struct lyd_node *input;
  struct nc_reply *reply
  struct nc_rpc *rpc;
  uint64_t msgid;

  input= lyd_new_path(NULL, ctx, "/example:my-rpc/parameter", "value",
                      LYD_ANYDATA_CONSTSTRING, LYD_PATH_OPT_UPDATE);

  rpc = nc_rpc_act_generic(input, NC_PARAMTYPE_CONST);
  nc_send_rpc(session, rpc, 1000, &msgid);
  nc_recv_reply(nc_session, rpc, msgid, 1000, &reply);  /* input is freed by parse_reply */

  nc_reply_free(reply);
  nc_rpc_free(rpc);
  lyd_free_withsiblings(input);  /* double free here */

If the rpc request data was allocated outside of parse_reply, it should
not be freed.

Only free it if it was allocated in parse_reply().

Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
@michalvasko
Copy link
Copy Markdown
Member

Hi,
you are right but I thought adding a new flag was not really needed so I fixed it myself. Thanks.

Regards,
Michal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants