diff --git a/asc2log.c b/asc2log.c index 7f932ef..ea6b486 100644 --- a/asc2log.c +++ b/asc2log.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -206,6 +207,13 @@ void eval_can(char* buf, struct timeval *date_tvp, char timestamps, char base, i if (strlen(dir) != 2) /* "Rx" or "Tx" */ return; + /* check for signed integer overflow */ + if (dplace == 4 && read_tv.tv_usec >= INT_MAX / 100) + return; + + if (dplace == 5 && read_tv.tv_usec >= INT_MAX / 10) + return; + if (dir[0] == 'R') extra_info = " R\n"; else @@ -269,6 +277,14 @@ void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps, int dplace if (strlen(dir) != 2) /* "Rx" or "Tx" */ return; + /* check for signed integer overflow */ + if (dplace == 4 && read_tv.tv_usec >= INT_MAX / 100) + return; + + /* check for signed integer overflow */ + if (dplace == 5 && read_tv.tv_usec >= INT_MAX / 10) + return; + if (dir[0] == 'R') extra_info = " R\n"; else