canplayer: ensure 6 decimal places in timestamp for first frame

The check has only been applied after the first CAN frame has been read
and evaluated. This lead to an unintended sending of a single handcrafted
frame with a following (intended) failure at the second frame.

Apply the check also for the very first CAN frame that is processed.

Fixes: ee0233505b ("canplayer: ensure 6 decimal places in timestamp")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
pull/454/head
Oliver Hartkopp 2023-08-10 10:31:26 +02:00
parent 3aa72b8208
commit 79601bd1d4
1 changed files with 9 additions and 0 deletions

View File

@ -425,6 +425,15 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/*
* ensure the fractions of seconds are 6 decimal places long to catch
* 3rd party or handcrafted logfiles that treat the timestamp as float
*/
if (strchr(buf, ')') - strchr(buf, '.') != 7) {
fprintf(stderr, "timestamp format in logfile requires 6 decimal places\n");
return 1;
}
if (use_timestamps) { /* throttle sending due to logfile timestamps */ if (use_timestamps) { /* throttle sending due to logfile timestamps */
gettimeofday(&today_tv, NULL); gettimeofday(&today_tv, NULL);