summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-02 12:08:29 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-03-24 13:59:32 +1030
commit4ca1aa5931de40d2849b2f1369eaaf51c6fd02f5 (patch)
treeb4be7ab38be1c5b15228c80f64274948d6e5128b
parentf5a5138fb1bdea02b3ba4effa06cfd2262956723 (diff)
downloadphosphor-mboxd-4ca1aa5931de40d2849b2f1369eaaf51c6fd02f5.zip
phosphor-mboxd-4ca1aa5931de40d2849b2f1369eaaf51c6fd02f5.tar.gz
pnor_partition_table: Disallow overlapping partitions
Change-Id: I25c6a6c4cee69ce9ba28c238851c7b7c622bb9b3 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--pnor_partition_table.cpp25
-rw-r--r--test/vpnor/Makefile.am.include2
2 files changed, 25 insertions, 2 deletions
diff --git a/pnor_partition_table.cpp b/pnor_partition_table.cpp
index 67b32f1..c9d56a2 100644
--- a/pnor_partition_table.cpp
+++ b/pnor_partition_table.cpp
@@ -99,6 +99,31 @@ void Table::preparePartitions()
parseTocLine(line, blockSize, part);
+ if (numParts > 0)
+ {
+ struct pnor_partition& prev = table.partitions[numParts - 1];
+ uint32_t prev_end = prev.data.base + prev.data.size;
+
+ if (part.data.id == prev.data.id)
+ {
+ MSG_ERR("ID for previous partition '%s' at block 0x%" PRIx32
+ "matches current partition '%s' at block 0x%" PRIx32
+ ": %" PRId32 "\n",
+ prev.data.name, prev.data.base, part.data.name,
+ part.data.base, part.data.id);
+ }
+
+ if (part.data.base < prev_end)
+ {
+ std::stringstream err;
+ err << "Partition '" << part.data.name << "' start block 0x"
+ << std::hex << part.data.base << "is less than the end "
+ << "block 0x" << std::hex << prev_end << " of '"
+ << prev.data.name << "'";
+ throw InvalidTocEntry(err.str());
+ }
+ }
+
file = directory / part.data.name;
if (!fs::exists(file))
{
diff --git a/test/vpnor/Makefile.am.include b/test/vpnor/Makefile.am.include
index 6765b02..831b146 100644
--- a/test/vpnor/Makefile.am.include
+++ b/test/vpnor/Makefile.am.include
@@ -137,6 +137,4 @@ check_PROGRAMS += \
%reldir%/toc_no_version \
%reldir%/toc_flags \
%reldir%/toc_overlap
-
-XFAIL_TESTS += %reldir%/toc_overlap
endif
OpenPOWER on IntegriCloud