diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c index 52ed496d92c3..53f1920c3fcb 100644 --- a/tools/perf/util/trace-event-read.c +++ b/tools/perf/util/trace-event-read.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "trace-event.h" #include "debug.h" @@ -180,6 +181,11 @@ static int read_ftrace_printk(struct tep_handle *pevent) if (!size) return 0; + if (size == UINT_MAX) { + pr_debug("invalid ftrace printk size\n"); + return -1; + } + buf = malloc(size + 1); if (buf == NULL) return -1; @@ -357,6 +363,11 @@ static int read_saved_cmdline(struct tep_handle *pevent) if (!size) return 0; + if (size == ULLONG_MAX) { + pr_debug("invalid saved cmdline size"); + return -1; + } + buf = malloc(size + 1); if (buf == NULL) { pr_debug("memory allocation failure\n");