Sashiko suggests we use some reasonable max number of args to avoid
overflows when reading perf.data files, do it.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
return 0;
}
+// Some reasonable arbitrary max for the number of command line arguments
+#define MAX_CMDLINE_NR 32768
+
static int process_cmdline(struct feat_fd *ff, void *data __maybe_unused)
{
struct perf_env *env = &ff->ph->env;
if (do_read_u32(ff, &nr))
return -1;
+ if (nr > MAX_CMDLINE_NR)
+ return -1;
+
env->nr_cmdline = nr;
cmdline = zalloc(ff->size + nr + 1);