[PATCH v2 23/29] edid-decode: DisplayID length checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- Only report DisplayID version discrepancy for a data block after verifying that the data block exists and is properly sized. The fail message is output after the block name instead of before the block name.
- Output hex bytes of non-zero filler when length is 1 or 2. We did the same for lengths longer than that in a previous commit.
- Output hex bytes that are skipped when the block length is longer than the number of bytes remaining in the DisplayID block.

Signed-off-by: Joe van Tunen <joevt@xxxxxxx>
---
 parse-displayid-block.cpp | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/parse-displayid-block.cpp b/parse-displayid-block.cpp
index dc2ec7b..269444b 100644
--- a/parse-displayid-block.cpp
+++ b/parse-displayid-block.cpp
@@ -1721,25 +1721,22 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
 		default:   data_block = "Unknown DisplayID Data Block (" + utohex(tag) + ")"; break;
 		}
 
-		if (version >= 0x20 && (tag < 0x20 || tag == 0x7f))
-			fail("Use of DisplayID v1.x tag for DisplayID v%u.%u.\n",
-			     version >> 4, version & 0xf);
-		if (version < 0x20 && tag >= 0x20 && tag <= 0x7e)
-			fail("Use of DisplayID v2.0 tag for DisplayID v%u.%u.\n",
-			     version >> 4, version & 0xf);
-
 		if (length < 3) {
-			// report a problem when the remaining bytes are not 0.
+		// Report a problem when the remaining bytes are not 0.
+		data_block.clear(); // Probably not a Data Block so clear this.
 		if (tag || (length > 1 && x[1])) {
+			printf("  Filler:\n");
 			fail("Not enough bytes remain (%d) for a DisplayID data block and the DisplayID filler is non-0.\n", length);
+			hex_block("    ", x, length);
 			}
 		return length;
 		}
 
-	unsigned block_rev = x[1] & 0x07;
-
 		if (length < len + 3) {
+		data_block.clear(); // Probably not a Data Block so clear this.
+		printf("  Filler:\n");
 			fail("The length of this DisplayID data block (%d) exceeds the number of bytes remaining (%d).\n", len + 3, length);
+		hex_block("    ", x, length);
 		return length;
 		}
 
@@ -1756,6 +1753,15 @@ unsigned edid_state::displayid_block(const unsigned version, const unsigned char
 
 		printf("  %s:\n", data_block.c_str());
 
+	if (version >= 0x20 && (tag < 0x20 || tag == 0x7f))
+		fail("Use of DisplayID v1.x tag for DisplayID v%u.%u.\n",
+			 version >> 4, version & 0xf);
+	if (version < 0x20 && tag >= 0x20 && tag <= 0x7e)
+		fail("Use of DisplayID v2.0 tag for DisplayID v%u.%u.\n",
+			 version >> 4, version & 0xf);
+
+	unsigned block_rev = x[1] & 0x07;
+
 		switch (tag) {
 	case 0x00: parse_displayid_product_id(x); break;
 	case 0x01: parse_displayid_parameters(x); break;
-- 
2.24.3 (Apple Git-128)




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux