[PATCH] libtraceevent: Check type string length in eval_type_str()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The pointer type check unconditionally accesses len - 2 and it could
be a problem when the given type string broken or malicious.  Also the
shortest supported type length is 2 (s8 and u8).  So let's check the
length first to prevent invalid access.

Actually this was found in a fuzzer test.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
 src/event-parse.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/event-parse.c b/src/event-parse.c
index f862f49..e4b337c 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -2437,6 +2437,10 @@ eval_type_str(unsigned long long val, const char *type, int pointer)
 	int len;
 
 	len = strlen(type);
+	if (len < 2) {
+		do_warning("invalid type: %s", type);
+		return val;
+	}
 
 	if (pointer) {
 
-- 
2.36.0.550.gb090851708-goog




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux