diff mbox series

[v2,04/29] edid-decode: check cta_hdr10plus length

Message ID 20210926083330.5206-5-joevt@shaw.ca (mailing list archive)
State New, archived
Headers show
Series edid-decode: bug fixes, additions, changes | expand

Commit Message

joevt Sept. 26, 2021, 8:33 a.m. UTC
- if the length is 0 then it cannot get Application Version. Output a fail message.
- cta_hdr10plus may output hex after "Application Version: %u". If the hex is longer than 16 characters, then more lines of hex will be output and they won't align with the first line.
Instead, always start the hex on a new line.

Signed-off-by: Joe van Tunen <joevt@shaw.ca>
---
 parse-cta-block.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index f018df5..6607426 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -1133,11 +1133,12 @@  static void cta_microsoft(const unsigned char *x, unsigned length)
 
 static void cta_hdr10plus(const unsigned char *x, unsigned length)
 {
-	printf("    Application Version: %u", x[0]);
-	if (length > 1)
-		hex_block("  ", x + 1, length - 1);
-	else
-		printf("\n");
+	if (length == 0) {
+		fail("Empty Data Block with length %u.\n", length);
+		return;
+	}
+	printf("    Application Version: %u\n", x[0]);
+	hex_block("    ", x + 1, length - 1);
 }
 
 // Convert a PQ value (0-1) to cd/m^2 aka nits (0-10000)