From 2bdb93924e2e7b6b7243a6353ac08b62b99cfbb1 Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Sun, 1 May 2022 13:02:08 +0200 Subject: [PATCH] asc2log: make sure we have read the dlc value with sscanf() Signed-off-by: Oliver Hartkopp --- asc2log.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/asc2log.c b/asc2log.c index 47b5f7e..805d017 100644 --- a/asc2log.c +++ b/asc2log.c @@ -170,6 +170,9 @@ void eval_can(char* buf, struct timeval *date_tvp, char timestamps, char base, i &data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], &data[7]); + if (items < 7 ) /* make sure we've read the dlc */ + return; + if ((items == dlc + 7 ) || /* data frame */ ((items == 6) && (rtr == 'r')) || /* RTR without DLC */ ((items == 7) && (rtr == 'r'))) { /* RTR with DLC */ @@ -185,6 +188,9 @@ void eval_can(char* buf, struct timeval *date_tvp, char timestamps, char base, i &data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6], &data[7]); + if (items < 7 ) /* make sure we've read the dlc */ + return; + if ((items == dlc + 7 ) || /* data frame */ ((items == 6) && (rtr == 'r')) || /* RTR without DLC */ ((items == 7) && (rtr == 'r'))) { /* RTR with DLC */