rib: limit route prefix length in rib/register command

refs #4262

Change-Id: I567934419f6872cb0f5a823400f53014b9c6e85e
This commit is contained in:
Junxiao Shi
2018-02-01 21:59:44 +00:00
parent 3d2049fbc1
commit 75306351ff
5 changed files with 85 additions and 8 deletions
+9 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, Regents of the University of California,
/*
* Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,6 +28,7 @@
#include "readvertise/client-to-nlsr-readvertise-policy.hpp"
#include "readvertise/nfd-rib-readvertise-destination.hpp"
#include "core/fib-max-depth.hpp"
#include "core/logger.hpp"
#include "core/scheduler.hpp"
@@ -198,6 +199,12 @@ RibManager::registerEntry(const Name& topPrefix, const Interest& interest,
ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
if (parameters.getName().size() > FIB_MAX_DEPTH) {
done(ControlResponse(414, "Route prefix cannot exceed " + ndn::to_string(FIB_MAX_DEPTH) +
" components"));
return;
}
setFaceForSelfRegistration(interest, parameters);
// Respond since command is valid and authorized