From 4ff1b159dd6eb34249c4f2681daf295205897ee7 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 12 Jan 2023 18:17:55 +0100 Subject: [PATCH] pcie: use scanff instead of istringstream Signed-off-by: Steffen Vogel --- common/lib/kernel/pci.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lib/kernel/pci.cpp b/common/lib/kernel/pci.cpp index dbf2b620b..9199f0dd4 100644 --- a/common/lib/kernel/pci.cpp +++ b/common/lib/kernel/pci.cpp @@ -378,7 +378,8 @@ uint32_t Device::readHostBar(unsigned barNum) const throw RuntimeError("Failed to read resource file"); unsigned long long start, end, flags; - std::istringstream(line) >> std::hex >> start >> end >> flags; + if (std::sscanf(line.c_str(), "%llx %llx %llx", &start, &end, &flags) != 3) + throw SystemError("Failed to parse BAR line"); if (end > start) throw SystemError("Invalid BAR: start={}, end={}", start, end);