aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2020-11-21 12:10:07 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2020-11-21 12:10:07 +0100
commit86f098a425cd4ef9d699dc390f71a294fcf259a4 (patch)
tree34d0afa5c3f1aec21bcdb02f77c3c91865a6d41d
parentff4b82e4004db6789576f722bba4057d256b647f (diff)
edid-decode: improve Block Map checks
The Block Map code was missing sanity checks and it contained a bug as well where the block number was used instead of the block tag, so the block name was reported incorrectly. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--edid-decode.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/edid-decode.cpp b/edid-decode.cpp
index f1ba1e2..87c4364 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -964,7 +964,6 @@ void edid_state::parse_block_map(const unsigned char *x)
unsigned offset = 1;
unsigned i;
- printf("%s\n", block.c_str());
if (block_nr == 1)
block_map.saw_block_1 = true;
else if (!block_map.saw_block_1)
@@ -982,11 +981,18 @@ void edid_state::parse_block_map(const unsigned char *x)
fail("Valid block tags are not consecutive.\n");
fail_once = true;
}
- printf(" Block %3u: %s\n", block, block_name(block).c_str());
- if (block >= num_blocks && !fail_once) {
- fail("Invalid block number %u.\n", block);
+ printf(" Block %3u: %s\n", block, block_name(x[i]).c_str());
+ if (block >= num_blocks) {
+ if (!fail_once)
+ fail("Invalid block number %u.\n", block);
fail_once = true;
+ } else if (x[i] != edid[block * EDID_PAGE_SIZE]) {
+ fail("Block %u tag mismatch: expected 0x%02x, but got 0x%02x.\n",
+ block, edid[block * EDID_PAGE_SIZE], x[i]);
}
+ } else if (block < num_blocks) {
+ fail("Block %u tag mismatch: expected 0x%02x, but got 0x00.\n",
+ block, edid[block * EDID_PAGE_SIZE]);
}
}
}

Privacy Policy