Skip to content

config_asymmetric_key: process aborts on assert() when diff references a removed keystore entry #598

@awesomenode

Description

@awesomenode

Hi!

When trying to remove certs from the server, libnetconf2 assertion killed the process. The RPC:

<ks:keystore>
  <ks:asymmetric-keys>
    <ks:asymmetric-key nc:operation="remove">
      <ks:name>server_key</ks:name>
    </ks:asymmetric-key>
  </ks:asymmetric-keys>
</ks:keystore>
<ts:truststore>
  <ts:certificate-bags nc:operation="remove">
    <ts:certificate-bag>
      <ts:name>ca_cert</ts:name>
    </ts:certificate-bag>
  </ts:certificate-bags>
</ts:truststore>
<ncs:netconf-server>
  <ncs:listen>
    <ncs:endpoints>
      <ncs:endpoint nc:operation="remove">
        <ncs:name>main_tls</ncs:name>
      </ncs:endpoint>
    </ncs:endpoints>
  </ncs:listen>
</ncs:netconf-server>

Apparently, it was because in config_asymmetric_key the assertion fails when a diff walks an asymmetric-key list entry (as a parent traversal with operation="none" or "delete") that is no longer present in the internal keystore->entries array.

I've attached a simple reproduction code that kind of simulates what is happening.

It seems that internally, libnetconf2's diff walker visits the asymmetric-key as a parent traversal after it's already removed from keystore->entries, and the assertion kills the server.

Maybe it'd be better if config_asymmetric_key would not assert() in this case and on "entry not found" during NC_OP_DELETE / NC_OP_NONE, it would return a error (or no-op for NC_OP_NONE) instead?

I'm using libnetconf2 version 4.2.14.

Thanks!

libnetconf2_bug_repro.zip

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