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: v4l2-info/cec-info: don't erase last two chars if string is too short
Author:  Hans Verkuil <[email protected]>
Date:    Mon Aug 10 16:44:45 2026 +0200

Make the code more robust: when concatenating flags strings we want to
remove the last two ', ' characters. But if no flags were added, then
that's missing and trying to erase them will abort the program.

Check first that the string is long enough.

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

 utils/common/v4l2-info.cpp    | 2 +-
 utils/libcecutil/cec-info.cpp | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=52a88f729238c257dbe88f111df5e4c87be25820
diff --git a/utils/common/v4l2-info.cpp b/utils/common/v4l2-info.cpp
index c9ad1ba06d0b..1f5a90623ca9 100644
--- a/utils/common/v4l2-info.cpp
+++ b/utils/common/v4l2-info.cpp
@@ -678,7 +678,7 @@ std::string dvflags2s(unsigned vsync, int val)
                s += "has CTA-861 VIC, ";
        if (val & V4L2_DV_FL_HAS_HDMI_VIC)
                s += "has HDMI VIC, ";
-       if (s.length())
+       if (s.length() >= 2)
                return s.erase(s.length() - 2, 2);
        return s;
 }
diff --git a/utils/libcecutil/cec-info.cpp b/utils/libcecutil/cec-info.cpp
index 74616bb514c0..0b0d56b91508 100644
--- a/utils/libcecutil/cec-info.cpp
+++ b/utils/libcecutil/cec-info.cpp
@@ -85,7 +85,7 @@ static std::string laflags2s(unsigned flags)
                s += "CDC-Only, ";
        if (flags & CEC_LOG_ADDRS_FL_CONFIG_FAILED)
                s += "Config-Failed, ";
-       if (s.length())
+       if (s.length() > 2)
                s.erase(s.length() - 2, 2);
        return s + ")";
 }
@@ -275,7 +275,7 @@ std::string cec_all_dev_types2s(unsigned types)
                s += "Audio System, ";
        if (types & CEC_OP_ALL_DEVTYPE_SWITCH)
                s += "Switch, ";
-       if (s.length())
+       if (s.length() >= 2)
                return s.erase(s.length() - 2, 2);
        return s;
 }
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to