log: System crash and reboot random when play any content on Netflix [1/1]
authorrui guo <rui.guo@amlogic.com>
Wed, 24 Nov 2021 09:59:15 +0000 (17:59 +0800)
committerBruno Martins <bgcngm@gmail.com>
Sat, 20 Jul 2024 21:19:50 +0000 (22:19 +0100)
PD#OTT-25875

Problem:
detected buffer overflow in memcpy

Solution:
The parameter checking

Verify:
RDK + S905X4

Change-Id: I7d41111e58a7c4667e0c527890e41766970b840b
Signed-off-by: rui guo <rui.guo@amlogic.com>
optee/log.c

index 247f1426a91ad79a0ba3f6665c51cce641559d5f..adf2bd0c57bf16431dfa26ee6ff2d29c14ef45a4 100644 (file)
@@ -159,6 +159,9 @@ static size_t log_print_text(char *buf, size_t size)
        if (size == 0)
                return 0;
 
+       /* Line_size Out-of-bounds check */
+       text_size = text_size < (OPTEE_LOG_LINE_MAX - 16) ? text_size : OPTEE_LOG_LINE_MAX - 16;
+
        do {
                const char *next = memchr(text, '\n', text_size);
                size_t line_size;