From 6b03dde9fd254d2369f383dc1fed326c712666b5 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 9 Mar 2023 22:30:11 +0000 Subject: [PATCH] tplg_parser: tokens: print a helpful error for invalid data Print out error data when invalid private data is found. Signed-off-by: Liam Girdwood --- tools/tplg_parser/tokens.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/tplg_parser/tokens.c b/tools/tplg_parser/tokens.c index 02c5e5216..b85256d8f 100644 --- a/tools/tplg_parser/tokens.c +++ b/tools/tplg_parser/tokens.c @@ -307,6 +307,7 @@ bool is_valid_priv_size(size_t size_read, size_t priv_size, struct snd_soc_tplg_vendor_array *array) { size_t arr_size, elem_size, arr_elems_size; + bool valid; arr_size = sizeof(struct snd_soc_tplg_vendor_array); @@ -334,5 +335,9 @@ bool is_valid_priv_size(size_t size_read, size_t priv_size, * check if size of data to be read from widget's private data * doesn't exceed private data's size. */ - return size_read + arr_size + arr_elems_size <= priv_size; + valid = size_read + arr_size + arr_elems_size <= priv_size; + if (!valid) + fprintf(stderr, "error: invalid private data size %zu read %zu array %zu elems %zu\n", + priv_size, size_read, arr_size, arr_elems_size); + return valid; }