Skip to content

Commit 5152822

Browse files
committed
[roc] Prevent PCI address with endpoint parsing
1 parent a1cedcd commit 5152822

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/ParameterTypes/PciAddress.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "ReadoutCard/ParameterTypes/PciAddress.h"
1717
#include <iomanip>
1818
#include <sstream>
19+
#include <regex>
1920
#include <boost/format.hpp>
2021
#include <boost/spirit/include/qi.hpp>
2122
#include "ExceptionInternal.h"
@@ -29,6 +30,12 @@ namespace
2930
{
3031
bool parseLspciFormat(const std::string& string, int& bus, int& slot, int& function)
3132
{
33+
// Reject a case of the pci address + endpoint ID like "3b:00.0:1"
34+
std::regex expr(".*:.*:.*");
35+
if (std::regex_search(string, expr)) {
36+
return false;
37+
}
38+
3239
using namespace boost::spirit::qi;
3340
return phrase_parse(string.begin(), string.end(), hex >> ":" >> hex >> "." >> hex, space, bus, slot, function);
3441
}

0 commit comments

Comments
 (0)