This is an automatic generated email to let you know that the following patch 
were queued:

Subject: edid-decode: check that there really are SVRs to resolve
Author:  Hans Verkuil <hverkuil-ci...@xs4all.nl>
Date:    Mon Jan 15 09:37:58 2024 +0100

Check if there are really SVRs that need resolving, and
verify that the SVR is in a valid range.

This fixes a segfault for a really crappy EDID.

Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>

 edid-decode.cpp     | 2 +-
 edid-decode.h       | 2 ++
 parse-cta-block.cpp | 8 ++++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

---

diff --git a/edid-decode.cpp b/edid-decode.cpp
index 515a3b5d5eff..250d08c0e711 100644
--- a/edid-decode.cpp
+++ b/edid-decode.cpp
@@ -1486,7 +1486,7 @@ int edid_state::parse_edid()
        block = "";
        block_nr = EDID_MAX_BLOCKS;
 
-       if (has_cta)
+       if (cta.has_svrs)
                cta_resolve_svrs();
 
        if (options[OptPreferredTimings])
diff --git a/edid-decode.h b/edid-decode.h
index b0e26b815ca4..e3e479f2a782 100644
--- a/edid-decode.h
+++ b/edid-decode.h
@@ -179,6 +179,7 @@ struct edid_state {
                cta.hf_eeodb_blocks = 0;
                cta.image_width = cta.image_height = 0;
                cta.block_number = 0;
+               cta.has_svrs = false;
                cta.first_svd = true;
                cta.supported_hdmi_vic_codes = cta.supported_hdmi_vic_vsb_codes 
= 0;
                memset(cta.vics, 0, sizeof(cta.vics));
@@ -309,6 +310,7 @@ struct edid_state {
                bool have_hf_vsdb, have_hf_scdb;
                unsigned hf_eeodb_blocks;
                unsigned block_number;
+               bool has_svrs;
                bool first_svd;
                unsigned supported_hdmi_vic_codes;
                unsigned supported_hdmi_vic_vsb_codes;
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 492e5d2b073d..26e71b0792f9 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -853,6 +853,7 @@ void edid_state::cta_print_svr(unsigned char svr, 
vec_timings_ext &vec_tim)
                } else {
                        printf("    %s\n", suffix);
                        vec_tim.push_back(timings_ext(svr, suffix));
+                       cta.has_svrs = true;
                }
        } else if (svr >= 145 && svr <= 160) {
                sprintf(suffix, "VTDB %3u", svr - 144);
@@ -862,6 +863,7 @@ void edid_state::cta_print_svr(unsigned char svr, 
vec_timings_ext &vec_tim)
                } else {
                        printf("    %s\n", suffix);
                        vec_tim.push_back(timings_ext(svr, suffix));
+                       cta.has_svrs = true;
                }
        } else if (svr >= 161 && svr <= 175) {
                sprintf(suffix, "RID %u@%up",
@@ -872,6 +874,7 @@ void edid_state::cta_print_svr(unsigned char svr, 
vec_timings_ext &vec_tim)
                } else {
                        printf("    %s\n", suffix);
                        vec_tim.push_back(timings_ext(svr, suffix));
+                       cta.has_svrs = true;
                }
        } else if (svr == 254) {
                sprintf(suffix, "T8VTDB");
@@ -882,6 +885,7 @@ void edid_state::cta_print_svr(unsigned char svr, 
vec_timings_ext &vec_tim)
                        sprintf(suffix, "DMT 0x%02x", cta.preparsed_t8vtdb_dmt);
                        printf("    %s\n", suffix);
                        vec_tim.push_back(timings_ext(svr, suffix));
+                       cta.has_svrs = true;
                }
        }
 }
@@ -2968,9 +2972,13 @@ void edid_state::cta_resolve_svr(timings_ext &t_ext)
                add_str(t_ext.flags, ">=CTA-861-H");
                t_ext.t = cta.t8vtdb.t;
        } else if (t_ext.svr() <= 144) {
+               if (t_ext.svr() < 129 || t_ext.svr() - 129 >= 
cta.vec_dtds.size())
+                       return;
                t_ext.flags = cta.vec_dtds[t_ext.svr() - 129].flags;
                t_ext.t = cta.vec_dtds[t_ext.svr() - 129].t;
        } else if (t_ext.svr() <= 160) {
+               if (t_ext.svr() - 145 >= cta.vec_vtdbs.size())
+                       return;
                t_ext.flags = cta.vec_vtdbs[t_ext.svr() - 145].flags;
                add_str(t_ext.flags, ">=CTA-861-H");
                t_ext.t = cta.vec_vtdbs[t_ext.svr() - 145].t;
_______________________________________________
linuxtv-commits mailing list -- linuxtv-commits@linuxtv.org
To unsubscribe send an email to linuxtv-commits-le...@linuxtv.org
%(web_page_url)slistinfo/%(_internal_name)s

Reply via email to