Actions
Task #4875
closedCanAddName callback can access a non-existing map entry
Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
03/12/2019
Due date:
% Done:
0%
Estimated time:
Description
The CanAddName callback in FullProducer checks if prefix
is not in m_prefixes
, or if m_prefixes[prefix] < seq)
https://github.com/8th-ndn-hackathon/PSync/blob/0fb388245a429e651ea15ac1f62696d4e5cfdbcb/PSync/full-producer.cpp#L53
if (m_prefixes.m_prefixes.find(prefix) == m_prefixes.m_prefixes.end() ||
m_prefixes.m_prefixes[prefix] < seq) {
uint64_t oldSeq = m_prefixes.m_prefixes[prefix];
if (oldSeq != 0) {
m_producerArbitrary.removeName(ndn::Name(prefix).appendNumber(oldSeq));
}
In the if clause, it gets oldSeq
from m_prefixes[prefix]
. But the if clause can be entered when prefix
is not in m_prefixes
, so getting oldSeq
could access a non-existing map entry. I think you need to check again. In the following, I also simplify m_prefixes.m_prefixes.find(prefix) == m_prefixes.m_prefixes.end()
to !m_prefixes.isUserNode(prefix)
if (!m_prefixes.isUserNode(prefix) ||
m_prefixes.m_prefixes[prefix] < seq) {
if (m_prefixes.isUserNode(prefix)) {
uint64_t oldSeq = m_prefixes.m_prefixes[prefix];
if (oldSeq != 0) {
m_producerArbitrary.removeName(ndn::Name(prefix).appendNumber(oldSeq));
}
}
Updated by Junxiao Shi 4 months ago
- Status changed from New to Closed
This code no longer exist in the mainline repository.
Actions