This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: edid-decode: detect extension blocks starting with EDID header
Author:  Hans Verkuil <[email protected]>
Date:    Mon Jul 13 09:32:23 2026 +0200

Bad EDID implementations can cause duplicate reads of the base
block. Typically the second N blocks read are a duplicate of the
first N blocks.

Detect if this happens and skip parsing the remaining blocks.

Signed-off-by: Hans Verkuil <[email protected]>

 utils/edid-decode/edid-decode.cpp | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=85818a7e66d943ed95b186bccf92d3fb26835984
diff --git a/utils/edid-decode/edid-decode.cpp 
b/utils/edid-decode/edid-decode.cpp
index d8a1c63a3e8f..78de5e685b07 100644
--- a/utils/edid-decode/edid-decode.cpp
+++ b/utils/edid-decode/edid-decode.cpp
@@ -23,6 +23,9 @@
 
 static edid_state state;
 
+static const unsigned char edid_hdr[8] = {
+       0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0
+};
 static unsigned char edid[EDID_PAGE_SIZE * EDID_MAX_BLOCKS];
 static bool odd_hex_digits;
 
@@ -1226,7 +1229,7 @@ static int edid_from_file(const char *from_file, FILE 
*error)
        if (fd != 0)
                close(fd);
 
-       if (memcmp(edid, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8)) {
+       if (memcmp(edid, edid_hdr, sizeof(edid_hdr))) {
                if (!options[OptPhysicalAddress])
                        fprintf(error, "No EDID header found in '%s'.\n", 
from_file);
                return -1;
@@ -1610,8 +1613,14 @@ int edid_state::parse_edid()
        if (replace_unique_ids)
                replace_checksum(edid, EDID_PAGE_SIZE);
 
-       for (unsigned i = 1; i < num_blocks; i++)
+       unsigned edid_num_blocks = num_blocks;
+       for (unsigned i = 1; i < num_blocks; i++) {
+               if (!memcmp(edid + i * EDID_PAGE_SIZE, edid_hdr, 
sizeof(edid_hdr))) {
+                       num_blocks = i;
+                       break;
+               }
                preparse_extension(edid + i * EDID_PAGE_SIZE);
+       }
 
        if (options[OptPhysicalAddress]) {
                printf("%x.%x.%x.%x\n",
@@ -1624,9 +1633,9 @@ int edid_state::parse_edid()
 
        if (!options[OptSkipHexDump]) {
                printf("edid-decode (hex):\n\n");
-               for (unsigned i = 0; i < num_blocks; i++) {
+               for (unsigned i = 0; i < edid_num_blocks; i++) {
                        hex_block("", edid + i * EDID_PAGE_SIZE, 
EDID_PAGE_SIZE, false);
-                       if (i == num_blocks - 1 && options[OptOnlyHexDump])
+                       if (i == edid_num_blocks - 1 && options[OptOnlyHexDump])
                                return 0;
                        printf("\n");
                }
@@ -1652,6 +1661,10 @@ int edid_state::parse_edid()
        block = "";
        block_nr = EDID_MAX_BLOCKS;
 
+       if (num_blocks < edid_num_blocks)
+               fail("Extension Block %u started with EDID header, ignoring 
Extension Blocks >= %u.\n",
+                    num_blocks, num_blocks);
+
        if (cta.has_svrs)
                cta_resolve_svrs();
 
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to