Project

General

Profile

Actions

Bug #4136

closed

PibSqlite3::setDefaultIdentity does not create the identity if it doesn't exist

Added by Anonymous almost 7 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Category:
Security
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:

Description

The documentation for setDefaultIdentity says "If identityName identity does not exist, it will be created":
https://github.com/named-data/ndn-cxx/blob/cbe72b07ace4020355f5d1df700ee671440998c9/src/security/pib/pib-impl.hpp#L124

But PibSqlite3::setDefaultIdentity does not do this:
https://github.com/named-data/ndn-cxx/blob/fe4733a1608712e389fe10b329a9fd61575ad075/src/security/pib/pib-sqlite3.cpp#L330

Suggestion: At the beginning of setDefaultIdentity, add the following lines from PibSqlite3::addIdentity:
https://github.com/named-data/ndn-cxx/blob/fe4733a1608712e389fe10b329a9fd61575ad075/src/security/pib/pib-sqlite3.cpp#L289

if (!hasIdentity(identity)) {
  Sqlite3Statement statement(m_database, "INSERT INTO identities (identity) values (?)");
  statement.bind(1, identity.wireEncode(), SQLITE_TRANSIENT);
  statement.step();
}
Actions

Also available in: Atom PDF