summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-02 11:54:22 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-03-24 13:59:32 +1030
commitdb4934103161b6a58673c2b0a00bebe4a44bbaa4 (patch)
tree5e67dfc5ca8b956dcd9d0186d57a94bfe1152deb
parent17bbf453661d8d5e498e0d34030d73e55b99311f (diff)
downloadphosphor-mboxd-db4934103161b6a58673c2b0a00bebe4a44bbaa4.tar.gz
phosphor-mboxd-db4934103161b6a58673c2b0a00bebe4a44bbaa4.zip
pnor_partition_table: Disallow ToC entries with start greater than end
Change-Id: If0861efb0f6bccf82a2df94204821f22198e17b0 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--pnor_partition_table.cpp8
-rw-r--r--test/vpnor/Makefile.am.include3
2 files changed, 8 insertions, 3 deletions
diff --git a/pnor_partition_table.cpp b/pnor_partition_table.cpp
index 646f0c3..19bee87 100644
--- a/pnor_partition_table.cpp
+++ b/pnor_partition_table.cpp
@@ -317,6 +317,14 @@ void parseTocLine(const std::string& line, size_t blockSize,
match[NAME_MATCH].str().c_str(), (end - start), blockSize);
}
+ if (start >= end)
+ {
+ std::stringstream err;
+ err << "Partition " << match[NAME_MATCH].str()
+ << " has an invalid range: start offset (0x" << std::hex << start
+ << " is beyond open end (0x" << std::hex << end << ")\n";
+ throw InvalidTocEntry(err.str());
+ }
writeSizes(part, start, end, blockSize);
// Use the shift to convert "80" to 0x80000000
diff --git a/test/vpnor/Makefile.am.include b/test/vpnor/Makefile.am.include
index 5c828d9..e70214e 100644
--- a/test/vpnor/Makefile.am.include
+++ b/test/vpnor/Makefile.am.include
@@ -89,7 +89,4 @@ check_PROGRAMS += \
%reldir%/write_patch \
%reldir%/toc_no_name \
%reldir%/toc_start_gt_end
-
-XFAIL_TESTS += \
- %reldir%/toc_start_gt_end
endif
OpenPOWER on IntegriCloud